使用 SqlWorkflowPersistenceService 时,在 PersistenceDBAccessor.RetrieveNonblockingInstanceStateIds 中获取 SqlException 死锁
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到答案了!
我应该使用启用锁定的 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