2

在 Windows Azure 中,我们有重试逻辑,使用瞬态故障处理应用程序块,它在我们的工作角色上按预期工作。但是,我们最近升级了我们的 SQL Azure 数据库以进行联合,并且从那时起遇到了一些问题。

我们的工作者角色偶尔会说某个特定的存储过程不存在。这是我们让它在运行循环中每秒检查的存储过程。角色遍历每个分片并在每个分片数据库上运行存储过程。这一切都很好,但是我们偶尔会在日志中收到错误,指出它找不到存储过程,调用堆栈表明 TransientFaultHandling 连接已重试。

看到我们的代码只是创建一个连接(保持打开)连接到一个分片,然后执行存储过程,我认为候选可能是,如果存在暂时性故障并且它重试连接,它可能最终连接回根数据库而不是它曾经连接的分片?

我的问题是 TransientFaultHandling 块是否正确解释了这一点并在重试连接时重新连接回正确的分片,如果没有,是否有这样做的最佳实践?

谢谢加雷斯

4

1 回答 1

0

I suspect that you are on the right track; the connection is probably reset to the root database. The Transient Fault Handling block will handle transient errors automatically but is not Federation aware as far as I know.

I wonder how your code is structured. But here is an idea (if that's not what you are already doing): You could use the application block to retry an entire piece of code that includes the connection request, the USE command (for federation) and the stored proc call. So if that fails, everything gets to be retried. You do that by creating a retry policy object (which would be the SQL database transient detection strategy), and call the ExecuteAction method that performs all the work you want done.

Hope this helps.

Herve

于 2012-09-06T21:27:41.660 回答