使用 SqlWorkflowPersistenceService 时,在 PersistenceDBAccessor.RetrieveNonblockingInstanceStateIds 中获取 SqlException 死锁

发布于 2024-08-25 05:12:18 字数 1309 浏览 2 评论 0原文

我正在使用 WF 3.5,在启动几个 WorkflowRuntime 的过程中,有时会出现以下异常:

System.Data.SqlClient.SqlException: Transaction (Process ID 108) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.HasMoreRows()
   at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
   at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveNonblockingInstanceStateIds(Guid ownerId, DateTime ownedUntil)
   at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.RecoverRunningWorkflowInstances()
   at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.OnStarted()
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at System.Workflow.Runtime.WorkflowRuntime.StartRuntime()

我认为运行多个 WorkflowRuntime 是可以的。我正在旋转多个服务器,因为我将工作负载分配到不同的服务器,但所有服务器都访问同一个数据库。有什么想法吗?

I'm using WF 3.5 and during the process of spinning up a couple of WorkflowRuntimes, I sometimes get the following exception:

System.Data.SqlClient.SqlException: Transaction (Process ID 108) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.HasMoreRows()
   at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
   at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveNonblockingInstanceStateIds(Guid ownerId, DateTime ownedUntil)
   at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.RecoverRunningWorkflowInstances()
   at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.OnStarted()
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at System.Workflow.Runtime.WorkflowRuntime.StartRuntime()

I thought running multiple WorkflowRuntimes was ok. I'm spinning up multiples because I'm distributing the work load to different servers, but all are hitting the same database. Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心空情空意 2024-09-01 05:12:18

找到答案了!

我应该使用启用锁定的 SqlWorkflowPersistenceService 构造函数:

SqlWorkflowPersistenceService 构造函数(字符串、布尔值、TimeSpan、TimeSpan)
http://msdn.microsoft.com/en -us/library/ms608171(v=VS.90).aspx

有关详细信息:https://connect.microsoft.com/wf/feedback/details/541240/sqlexception-deadlock-in-persistencedbaccessor-retrievenonblockinginstancestateids

Found the answer!

I should have used the SqlWorkflowPersistenceService constructor that enables locking:

SqlWorkflowPersistenceService Constructor (String, Boolean, TimeSpan, TimeSpan)
http://msdn.microsoft.com/en-us/library/ms608171(v=VS.90).aspx

For more information: https://connect.microsoft.com/wf/feedback/details/541240/sqlexception-deadlock-in-persistencedbaccessor-retrievenonblockinginstancestateids

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文