2011-12-06 113 views
2

返回也许任何你可以帮我这个是烦人的问题。我有很长时间运行的工作流程,这是长时间运行的应用程序使用的。
我使用SqlWorkflowInstanceStore进行持久化。
我设置DefaultInstanceOwner这样我就可以重新加载应用程序的其他启动工作流。InstanceOwnerException从睡眠

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(); 

一切都在正常使用应用的顺利。如果窗口进入睡眠模式,则会出现问题。当它从睡眠模式返回,其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当系统唤醒时。

任何想法,以找到根本原因针对此行为或解决方法是受欢迎的。我已经拿了第一个解决办法,那就是禁用休眠模式...

+0

很有意思 - 如果我能重现此我想对文件中的错误。你有简单的repro我可以看看吗? –

+0

这里同样的问题。你有没有找到其他解决方案? – olorin

+0

如果WorkflowInstanceOwner已失效,则解决方案确实会检查系统恢复。 – AlexP

回答

1

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

一个解决办法是重新启动实例存储时从睡眠模式恢复电脑。 您可以通过注册Microsoft.Win32.SystemEvents.PowerModeChanged事件来检测此情况。