persistence - WF4 InstancePersistenceCommand interrupted -
i have windows service, running workflows. workflows xamls loaded database (users can define own workflows using rehosted designer). configured 1 instance of sqlworkflowinstancestore, persist workflows when becoming idle. (it's derived example code in \controllingworkflowapplications microsoft's wcf/wf samples).
but error below:
system.runtime.durableinstancing.instanceownerexception: execution of instancepersistencecommand interrupted because instance owner registration owner id 'a426269a-be53-44e1-8580-4d0c396842e8' has become invalid. error indicates in-memory copy of instances locked owner have become stale , should discarded, along instancehandles. typically, error best handled restarting host.
i've been trying find cause, hard reproduce in development, on production servers however, once in while. 1 hint found : when @ lockownerstable, find lockonwerstable lockexpiration set 01/01/2000 0:0:0 , it's not getting updated anymore, while under normal circumstances should updated every x seconds according host lock renewal period...
so , why whould sqlworkflowinstancestore stop renewing lockexpiration , how can detect cause of it?
this happens because there procedures running in background , trying extend lock of instance store every 30 seconds, , seems once connection fail connecting sql service mark instance store invalid. can see same behaviour if delete instance store record [lockownerstable] table. proposed solution when exception fires, need free old instance store , initialize new 1
public class workflowinstancestore : iworkflowinstancestore, idisposable { public workflowinstancestore(string connectionstring) { _instancestore = new sqlworkflowinstancestore(connectionstring); instancehandle handle = _instancestore.createinstancehandle(); instanceview view = _instancestore.execute(handle, new createworkflowownercommand(), timespan.fromseconds(30)); handle.free(); _instancestore.defaultinstanceowner = view.instanceowner; } public instancestore store { { return _instancestore; } } public void dispose() { if (null != _instancestore) { var deleteowner = new deleteworkflowownercommand(); instancehandle handle = _instancestore.createinstancehandle(); _instancestore.execute(handle, deleteowner, timespan.fromseconds(10)); handle.free(); } } private instancestore _instancestore; }
you can find best practices create instance store handle in link workflow instance store best practices
Comments
Post a Comment