什么可能导致 DurableInstancing.InstanceNotReadyException,以及如何修复它?

发布于 2024-10-11 13:23:01 字数 1456 浏览 8 评论 0原文

我们有一个管理文档生命周期的业务逻辑。
这是使用 Workflow Foundation 4 和 WF Persistence 实现的。 在工作流执行期间,工作流中会创建某些书签,并且计划任务会定期查找所有特定书签并恢复工作流 (正在执行的活动会执行一些处理并再次为工作流添加书签,以便稍后可以恢复工作流。)

现在,对于工作流的某些正在运行的实例,我们收到以下错误:

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)

之前相同的实例已成功加载。

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

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

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 receive 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?

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

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

发布评论

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

评论(1

别挽留 2024-10-18 13:23:01

这是在您不断更改工作流程的开发机器上吗?我之前收到过此错误,并且必须清理我的持久性数据库。这是一个可以为您完成此操作的脚本。

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

让我知道这是否适合您!

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!

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