gpt4 book ai didi

windows - Windows 从 sleep 中返回后的 InstanceOwnerException

转载 作者:可可西里 更新时间:2023-11-01 10:39:16 25 4
gpt4 key购买 nike

也许你们中的任何人都可以帮助我解决这个烦人的问题。我有一个长时间运行的工作流程,由一个长时间运行的应用程序使用。
我使用 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 进入休眠模式,则会出现此问题。当它从 sleep 模式返回时,对 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。

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

最佳答案

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

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

关于windows - Windows 从 sleep 中返回后的 InstanceOwnerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8400100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com