locked
Multiple Worklfow Hosts Sharing the Same Database RRS feed

  • Question

  • I currently have two different workflow hosts implemented as windows services sharing the same database. Both hosts are using the SqlWorkflowPersistenceService with instanceOwnershipDuration equal to TimeSpan.Max, loadingInterval = 5 seconds and unloadOnIdle set to false.

    When HostA creates and loads a workflow and then shuts down (i.e. stopping the windows service), I see an entry in the InstanceState table for the WF instance. All is good. A few seconds later I see from querying this table that HostB loads the same workflow (the InstanceState table shows that ownderID = HostB's SqlWorkflowPersistenceService instanceID) and the ownedUntil column displays 9999-12-31 23:59:59.997 (presumably because ownershipDuration is TimeSpan.Max).

    However when I shut down HostB, none of the columns in the InstanceState table for this WF instance are changed - I would have expected the owerID and ownedUntil columns to be NULL and blocked to be 0. Additionally, the workflow never gets re-loaded when HostA restarts nor even when HostB restarts.

    Any ideas to resolve this would be greatly appreciated.

    Thanks.

    Friday, March 16, 2007 5:59 PM

Answers

  • Is HostB gracefully shutting down and calling workflowRuntime.StopRuntime() so that the workflows are persisted?  I would never recommend setting the InstanceOwnershipDuration to TimeSpan.Max, especially if you have UnloadOnIdle set to false.  If for some reason one of your hosts crashes before it manually persists the workflow no host will be able to process that instance in the future without hacking the persistence database.  Normally the ownership duration should be slightly longer than the longest possible length of time between persistence points.   Start with 20 or 30 minutes if you are unsure how long things take, in most cases this is more than sufficient.  If the host takes longer than that to complete its work and persist then it will get an exception that its ownership expired or it is owned by another runtime.

    Saturday, March 17, 2007 2:41 AM