2

我们拥有管理文档生命周期的业务逻辑。
这是使用Workflow Foundation 4和WF Persistence实现的。 在执行工作流程期间,在工作流程中创建了某些书签,并且计划任务定期查找所有特定书签并恢复工作流程(正在执行的活动执行一些处理并再次为工作流程添加书签,以便可以继续工作流程。后来)什么可能导致DurableInstancing.InstanceNotReadyException,我该如何解决它?

现在对于一些工作流程的运行情况,我们收到以下错误:

 
System.Runtime.DurableInstancing.InstanceNotReadyException was unhandled 
    Message=The execution of an InstancePersistenceCommand was interrupted because the instance '99ce9413-5b17-4de0-a453-46891509e032' has not yet been persisted to the instance store. 
    Source=System.Runtime.DurableInstancing 
    StackTrace: 
     at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) 
     at System.Runtime.DurableInstancing.InstancePersistenceContext.OuterExecute(InstanceHandle initialInstanceHandle, InstancePersistenceCommand command, Transaction transaction, TimeSpan timeout) 
     at System.Runtime.DurableInstancing.InstanceStore.Execute(InstanceHandle handle, InstancePersistenceCommand command, TimeSpan timeout) 
     at System.Activities.WorkflowApplication.PersistenceManager.Load(TimeSpan timeout) 
     at System.Activities.WorkflowApplication.LoadCore(TimeSpan timeout, Boolean loadAny) 
     at System.Activities.WorkflowApplication.Load(Guid instanceId, TimeSpan timeout) 
     at System.Activities.WorkflowApplication.Load(Guid instanceId) 

以前相同的情况下,已成功加载。

我有几个与此相关的异常问题:

  • 我们什么时候能得到这个例外?
  • 如果我们得到这个异常,是否有处理它的优雅方式,以便稍后可以恢复相同的实例?
  • 还有什么方法可以修复由于此异常而无法恢复的现有工作流实例吗?

回答

0

这是你的开发机器中,你一直在更改工作流程吗?我以前收到这个错误,不得不清理我的持久性数据库。这是一个脚本,将为您做到这一点。

use [AppFabricPersistenceStore] 

set nocount on 

declare @InstanceId uniqueidentifier 
declare @SurrogateInstanceId bigint 

declare csr cursor fast_forward for 
    select InstanceId from [System.Activities.DurableInstancing].Instances 

open csr 
fetch next from csr into @InstanceId 

while @@fetch_status = 0 
begin 
    (
     select @SurrogateInstanceId = SurrogateInstanceId 
     from [System.Activities.DurableInstancing].InstancesTable i 
     where i.Id = @InstanceId 
    ) 

    execute [System.Activities.DurableInstancing].DeleteInstance @SurrogateInstanceId 

    fetch next from csr into @InstanceId 
end 

close csr 
deallocate csr 

让我知道这是否适合您!

相关问题