Workflow Persistence not found in Persisted State Issue !! RRS feed

  • Question

  • Dear All,

    I am using SqlWorkflowPersistence service in my .net 2.0 c# windows applicaiton , the flow is:

    1. User Submits a incident - The worklow is started and saved.

    2. Manager Approves that Incident. 

    Now while Approving the Incident there are 3 DB operations that happen and if there is any issue in these operations (usually because of SQL timeouts)  the workflow instance is deleted from table 'InstanceState'.

    To fix this we move the Incident back to initial stage and ask the user to Submit and Approve again!. Because once Manager gets an error while approving , after that if he/she tries to Approve again they get the standard error  'workflow instance id not found in persistence store' because its already deleted.

    My Questions:

    How do I tackle this scenario , especially while Approve stage because if it's Submit then even if workflow is deleted then it can be newly created so there are not much issues.But in Approve stage that workflow is just resumed and if it's lost (deleted) we are not able to recover it via C# code.

    So in short, How do I prevent  Instance from Sql database when workflow is terminated.

    Saturday, April 23, 2016 3:54 PM

All replies

  • Some progress..

    In 'WorkflowPersistence' DB, we have SP 'InsertInstanceState' which deletes the instance. I commented the code which deletes the instance.

    Tested for few of scenarios so far by injecting errors in the application. Looks like its working BUT I am not sure if this is correct way.

    Can anyone please provide your inputs of any issues this approach may cause?.

     Part of the SP is shown below which I changed.


    @status=1 OR @status=3          

    /* DELETE FROM [dbo].[InstanceState] WHERE uidInstanceID=@uidInstanceID AND ((ownerID = @ownerID AND ownedUntil>=@now) 
     OR (ownerID IS NULL AND @ownerID IS NULL ))          

    Friday, April 22, 2016 8:24 AM
  • Any feedback on this anyone ?... 
    Monday, April 25, 2016 2:37 AM
  • Hi,

    Generally it's recommended to "logically remove" the definitions on your tables, and perform Termination of the workflow. Here is a discussion like your scenario:

    Deleting/Terminating a persisted workflow without loading the workflow

    Have a good day.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Angie Xu Friday, May 6, 2016 1:52 AM
    Wednesday, April 27, 2016 6:53 AM