WCF InstancePersistenceCommand Exception

Juan Jimenez 1 Reputation point
2022-01-14T20:25:59.847+00:00

I have a WCF application which consists in some async communications with ecternal services. When we start a new expedient, a new instance is created; it process data and send an xml to a external service and waits for the response. This response requires that a person review the xml and send the response so it usually it is delayed for a long time. For this reason, the workflow go to idle and we use persistence with AppFabric.

The fact is that sometime, when we receive the response, the next exception is raised:

The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}LoadWorkflowByInstanceKey was interrupted by an error.

Normally this error does not occur, it can occur very sporadically. However, we are trying to update the app to include a new functionality (it does not modify the workflow) but when the application is deployed to the server, the instances that were created with the old deployment and were waiting for the response, throw this exception when they receive the response from the external service. However, the instances initiated with the new deployment process the response without problem.

I have been looking for information about this problem but I haven't found much. Anybody can help my? Thanks

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,786 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lan Huang-MSFT 29,166 Reputation points Microsoft Vendor
    2022-01-17T02:19:14.453+00:00

    Hi @Juan Jimenez ,
    The bug is closely related to the HostLockRenewalPeriod property, which defines how long the obtained instance handle is valid without being updated.
    You can try setting <workflowIdle timeToUnload="0"/>, a service behavior that controls when idle workflow instances are unloaded and persisted.
    https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/windows-workflow-foundation/workflowidle?redirectedfrom=MSDN
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Juan Jimenez 1 Reputation point
    2022-01-30T14:41:29.507+00:00

    Thanks a lot for your answer, it may be helpful for me in the future. In this case, the problem was that I was updating an assembly version of one of the implicated project (to upload a nuget package) and for a reason that I don’t understand, the instances created with an old version raised this exception when the service with the new version had to manipulate the mentioned instances.

    If I change the assembly version to upload the nuget and then set the original version and deploy with this version, everything works ok. Anybody knows what is the reason?

    Thanks a lot.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.