Windows 从睡眠状态返回后出现 InstanceOwnerException

发布于 2024-12-19 13:26:24 字数 1447 浏览 4 评论 0原文

也许你们中的任何人都可以帮助我解决这个恼人的问题。我有长时间运行的工作流程,由长时间运行的应用程序使用。
我使用 SqlWorkflowInstanceStore 进行持久化。
我设置了 DefaultInstanceOwner,以便可以在应用程序的另一次启动时重新加载工作流程。

InstanceHandle handle = workflowInstanceStore.CreateInstanceHandle();
InstanceView view = workflowInstanceStore.Execute(handle, 
                          new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
handle.Free();
workflowInstanceStore.DefaultInstanceOwner = view.InstanceOwner;

我在应用程序退出时将其删除:

 var deleteOwnerCmd = new DeleteWorkflowOwnerCommand();
 InstanceHandle handle = workflowInstanceStore.CreateInstanceHandle();
 workflowInstanceStore.Execute(handle, deleteOwnerCmd, TimeSpan.FromSeconds(30));
 handle.Free();

在正常应用程序使用下一切顺利。如果 Windows 进入睡眠模式,就会出现此问题。当它从睡眠模式返回时,使用workflowInstanceStore的任何其他操作都会抛出:

System.Runtime.DurableInstancing.InstanceOwnerException: The execution of an InstancePersistenceCommand was interrupted because the instance owner registration for owner ID 'GUID' has become invalid. This error indicates that the in-memory copy of all instances locked by this owner have become stale and should be discarded, along with the InstanceHandles. Typically, this error is best handled by restarting the host.

我查看了LockOwnersTable中的数据库,当系统启动时,锁过期时间设置为2000-01-01 00:00:00.000醒来。

欢迎任何找到此行为的根本原因或解决方法的想法。我已经采取了第一个解决方法,即禁用睡眠模式......

Perhaps any of you can help me with this anoying problem. I have long running workflow, that is used by a long running application.
I use the SqlWorkflowInstanceStore for persistence.
I set the DefaultInstanceOwner so I can reload the workflows on another startup of the app.

InstanceHandle handle = workflowInstanceStore.CreateInstanceHandle();
InstanceView view = workflowInstanceStore.Execute(handle, 
                          new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
handle.Free();
workflowInstanceStore.DefaultInstanceOwner = view.InstanceOwner;

and I delete it at app exit :

 var deleteOwnerCmd = new DeleteWorkflowOwnerCommand();
 InstanceHandle handle = workflowInstanceStore.CreateInstanceHandle();
 workflowInstanceStore.Execute(handle, deleteOwnerCmd, TimeSpan.FromSeconds(30));
 handle.Free();

Everything goes well under normal app use. The problem occurs if windows gets into sleep mode. When it returns from the sleep mode, any other operation with the workflowInstanceStore throws:

System.Runtime.DurableInstancing.InstanceOwnerException: The execution of an InstancePersistenceCommand was interrupted because the instance owner registration for owner ID 'GUID' has become invalid. This error indicates that the in-memory copy of all instances locked by this owner have become stale and should be discarded, along with the InstanceHandles. Typically, this error is best handled by restarting the host.

I took a look in the database in the LockOwnersTable and the lock expiration is set to 2000-01-01 00:00:00.000 when the system wakes up.

Any ideas to find the root cause for this behavior or workarounds are welcome. I already took the first workaround, that is disabled sleep mode...

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

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

发布评论

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

评论(1

够运 2024-12-26 13:26:25

我认为这种行为的原因是工作流实例存储应该告诉数据库它仍然以固定的时间间隔(由 HostLockRenewalPeriod 属性定义)活动。当计算机处于睡眠模式时,它无法更新 LockOwnersTable 的 LockExpiration 列,并且工作流实例存储被视为已失效。

解决方案是当计算机从睡眠模式恢复时重新启动实例存储。
您可以通过注册 Microsoft.Win32.SystemEvents.PowerModeChanged 事件来检测这一点。

I think the cause of this behavior, is that the workflow instance store is supposed to tell the database it is still alived at regular time interval (defined by the HostLockRenewalPeriod property). When the computer is in sleep mode it can not update the LockExpiration column of LockOwnersTable, and the workflow instance store is considered defunct.

A solution is to restart the instance store when the computer resume from sleep mode.
You can detect this by registering the Microsoft.Win32.SystemEvents.PowerModeChanged event.

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