我们有一个 SQL Server 2014 AlwaysOn 可用性组,我们通过标准 C# SqlConnection
对象连接到该组。我们希望捕获手动或自动触发故障转移时发生的异常,并在等待一段时间后重试该命令。
我们不想重试每条失败的命令,只想重试因故障转移而失败的事务。
Microsoft 是否提供我们可以检查的错误代码列表(或某处有列表)?
最佳答案
Microsoft 已经为 Azure 构建了一个 transient 错误检测策略,用于 transient 故障处理应用程序 block 。
The Transient Fault Handling Application Block (Topaz) makes your application more robust by providing the logic for handling transient faults. It does this in two ways.
First, the block includes logic to identify transient faults for a number of common cloud-based services in the form of detection strategies. These detection strategies contain built-in knowledge that is capable of identifying whether a particular exception is likely to be caused by a transient fault condition.
他们已经确定了表明暂时性故障的 sql 错误代码。虽然它是针对云(针对 Azure Sql Server)的,但我们已在我们自己的本地环境中成功使用了它。
你可以看看他们的代码并提取你可以检查的sql代码:
关于c# - 应该允许重试哪些 SQL 错误代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40798934/