SQL Azure数据库的重试逻辑

编程入门 行业动态 更新时间:2024-10-08 13:35:17
本文介绍了SQL Azure数据库的重试逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已实现了以下code写入到Azure数据库处理时,INSERT / UPDATE重试逻辑与指数退避。

I have implemented the following code for handling INSERT/UPDATE retry logic with exponential backoff when writing to an Azure Database.

static SqlConnection TryOpen(this SqlConnection connection) { int attempts = 0; while (attempts < 5) { try { if (attempts > 0) System.Threading.Thread.Sleep(((int)Math.Pow(3, attempts)) * 1000); connection.Open(); return connection; } catch { } attempts++; } throw new Exception("Unable to obtain a connection to SQL Server or SQL Azure."); }

不过,我应该考虑应用重试逻辑我的数据库中读取呢?或将在SqlCommand.CommandTimeout()方法就足够了?我的大部分读取使用以下code被提起:

However should I consider applying retry logic for my database reads as well? Or would the SqlCommand.CommandTimeout() method suffice? Most of my reads are instituted using the following code:

Dim myDateAdapter As New SqlDataAdapter(mySqlCommand) Dim ds As New DataSet myDateAdapter.Fill(ds, "dtName")

这是很难知道什么会发生在生产环境中使用Azure的,所以我想现在要做的尽可能多的缓解可能的排序瞬态错误的。

It's hard to know what sort of transient errors will occur in a production environment with Azure so I am trying to do as much mitigation as possible now.

推荐答案

我觉得重试将要在你的一般的Windows Azure SQL数据库操作的一部分。

I think retries are going to be part of your Windows Azure SQL Database operations in general.

而不是实现自定义的解决方案,你看了的瞬态故障处理应用程序块由Microsoft模式与实践发表,专为SQL数据库?

Rather than implementing a custom solution, have you looked at the transient fault handling application block published by Microsoft Patterns and Practices, specifically for SQL Database?

更多推荐

SQL Azure数据库的重试逻辑

本文发布于:2023-11-26 07:44:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633237.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重试   逻辑   数据库   SQL   Azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!