locked
Suspend WorkflowInstance using WorkflowControlEndpoint RRS feed

  • Question

  • The following scenario is required by our workflow system:

    • The workflows are hosted on IIS using AppFabric.
    • Workflow A is started on Machine 1 and is a long running workflow which can be persisted during the execution.
    • On machine 2 a control workflow is started which should suspend the execution of workflow A at any time.

    I use the WorkflowControlClient to send the request to the WorkflowControlEndpoint. When executing this the following exception occurs:

    The execution of an InstancePersistenceCommand was interrupted because the instance '2d10c403-9423-47cf-a2a0-91d141e6f908' is locked by a different instance owner. This error usually occurs because a different host has the instance loaded. The instance owner ID of the owner or host with a lock on the instance is '42f2b0c6-bd8a-4d8f-ba82-ddc90adba449'. Server stack trace:
      at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
      at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
      at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
      at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]:
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at System.ServiceModel.Activities.IWorkflowInstanceManagement.Suspend(Guid instanceId, String reason)
      at System.ServiceModel.Activities.WorkflowControlClient.Suspend(Guid instanceId)

    Web.config details of Workflow A:

    <serviceDebug includeExceptionDetailInFaults="true" />
    <sqlWorkflowInstanceStore instanceCompletionAction="DeleteAll" 
    						instanceEncodingOption="GZip" 
    						instanceLockedExceptionAction="BasicRetry" 
    						connectionStringName="ApplicationServerWorkflowInstanceStoreConnectionString99" 
    						hostLockRenewalPeriod="00:00:10" runnableInstancesDetectionPeriod="00:00:05" />
    <workflowInstanceManagement authorizedWindowsGroup="AS_Administrators" />
    <workflowUnhandledException action="AbandonAndSuspend" />
    <workflowIdle timeToPersist="10675199.02:48:05.4775807" timeToUnload="00:00:00" />

    Web.config details of the control workflow:

    <serviceDebug includeExceptionDetailInFaults="true" />
    <sqlWorkflowInstanceStore connectionStringName="ApplicationServerWorkflowInstanceStoreConnectionString5" 
    						hostLockRenewalPeriod="00:00:10" 
    						runnableInstancesDetectionPeriod="00:00:05" 
    						instanceEncodingOption="GZip" 
    						instanceCompletionAction="DeleteAll" 
    						instanceLockedExceptionAction="BasicRetry" />
    <workflowInstanceManagement authorizedWindowsGroup="AS_Administrators" />
    <workflowUnhandledException action="AbandonAndSuspend" />
    <workflowIdle timeToPersist="10675199.02:48:05.4775807" timeToUnload="00:00:00" />
    Is there a way to disable this lock of the owner?

    Or is there anything else I would have to configure in the web.config?
    • Moved by Andrew_Zhu Wednesday, February 16, 2011 5:54 AM (From:.NET 4: Windows Workflow Foundation)
    Monday, February 14, 2011 12:43 PM

Answers

  • Hi,

    this excpetion is generated when you try to load a workflow instance on a machine that is already loaded on a different machine. When you suspend a workflow instance the service host needs to load that instance. There are three ways you can tackle this:

    1. Invoke the instance control enpoint's Suspend() method to the machine that has the workflow instance loaded.

    2. Make sure the workflow instance is unloaded at the time you issue the suspend command. Looking at your config file the workflow instance should immediately be unloaded as soon as it becomes idle (timeToUnload="00:00:00") . I assume the workflow is not idle. Either it is in the middle of an activity, or it is in the middle of a no-persist zone. While being in such a zone the workflow cannot persist and, consequently, not be unloaded. Examples of no-persist zones are transaction scopes, send-receive pairs, receive-send pairs, waiting for an asynchronous callback, executing an activity.

    3. Use the AppFabric's Workflow Management Service to suspend the workflow instance. The command will be issued to the machine that has your instance loaded.

    Note that option 1 and 3 also require that the workflow can persist. The execution of the suspend command is delayed until the workflow instance can be persisted. You would not see the locking error in this case.

    • Proposed as answer by edhickey Tuesday, March 29, 2011 6:09 PM
    • Marked as answer by Ben Cline1Moderator Saturday, July 16, 2011 1:03 AM
    Wednesday, March 2, 2011 5:15 PM
    Moderator

All replies

  • Hi,

    You cannot disable the lock of the owner.

    If control workflow will try to suspend a workflow which is executing, it will get an exception. Control workflow should suspend workflow only when it has persisted as at this time the host has unlocked the instance.

    Regards,

    Sneha

    Monday, February 14, 2011 1:06 PM
  • Hi Sneha,

    Thanks for your fast reply.
    I have already ensured that Workflow A is persisted (instance is waiting in Receive Activities).
    Even then I got the same exception when sending the Control command with the control workflow.

    How does the lock work in detail and can I free the instance somehow?
    Monday, February 14, 2011 3:11 PM
  • Hi,

    this excpetion is generated when you try to load a workflow instance on a machine that is already loaded on a different machine. When you suspend a workflow instance the service host needs to load that instance. There are three ways you can tackle this:

    1. Invoke the instance control enpoint's Suspend() method to the machine that has the workflow instance loaded.

    2. Make sure the workflow instance is unloaded at the time you issue the suspend command. Looking at your config file the workflow instance should immediately be unloaded as soon as it becomes idle (timeToUnload="00:00:00") . I assume the workflow is not idle. Either it is in the middle of an activity, or it is in the middle of a no-persist zone. While being in such a zone the workflow cannot persist and, consequently, not be unloaded. Examples of no-persist zones are transaction scopes, send-receive pairs, receive-send pairs, waiting for an asynchronous callback, executing an activity.

    3. Use the AppFabric's Workflow Management Service to suspend the workflow instance. The command will be issued to the machine that has your instance loaded.

    Note that option 1 and 3 also require that the workflow can persist. The execution of the suspend command is delayed until the workflow instance can be persisted. You would not see the locking error in this case.

    • Proposed as answer by edhickey Tuesday, March 29, 2011 6:09 PM
    • Marked as answer by Ben Cline1Moderator Saturday, July 16, 2011 1:03 AM
    Wednesday, March 2, 2011 5:15 PM
    Moderator