开发者

What could be causing a DurableInstancing.InstanceNotReadyException, and how can I fix it?

We have a business logic for managing the document life cycle.

This is implemented using Workflow Foundation 4 and WF Persistence. During the execution of the workflow, certain bookmarks are created in the workflow and a scheduled task periodically finds all the specific bookmarks and resumes the workflow (The activity being executed does some processsing and bookmarks the workflow again so that the workflow can be resumed later.)

Now for some of the running instances of the workflow, we receiv开发者_JAVA技巧e the following error:

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)

previously the same instances were loaded successfully.

I have a couple of questions related to this exception:

  • When can we get this exception?
  • If we get this exception is there any graceful way of handling it so that the same instances can be resumed later?
  • Also is there any way of fixing the existing workflow instances which could not be resumed because of this exception?


Is this on your development machine in which you are consistently making changes to the workflows? I have received this error before and had to clean my persistence database. Here is a script that will do that for you.

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

Let me know if this works for you!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜