Molnar Tibor

blog

  Home  |   Contact  |   Syndication    |   Login
  21 Posts | 10 Stories | 35 Comments | 2 Trackbacks

News

Archives

Post Categories

Image Galleries

Context
In a production environment we started to receive, apparently randomly this error message. We have a complex workflow using InfoPath forms developed in Visual Studio, we applied multiple patches by regac-ing new versions of the workflow assemblies, retaining of course the fully qualified names of the assemblies. Also we use a test environment, where regression testing was done by dedicated test engineers.

Shooting in the dark
We found this blog http://geek.hubkey.com/2007/09/locked-workflow.html, which suggested to set the task item workflow version attribbute to 1 (task[SPBuiltInFieldId.WorkflowVersion] = 1;). It solved only temporary the problem, the following access to the task locked again the workflow.
Digging into the sharepoint assemblies, I found out that in Microsoft.SharePoint.dll assembly in the Microsoft.SharePoint.Workflow.SPWinOEItemReceiver class in the ItemUpdating is created the exception causing the "This task is currently locked by a running workflow and cannot be edited" message:

properties.ErrorMessage = SPResource.GetString("WorkflowTaskLocked", new object[0]);

The exception was thrown if the "WorkflowVersion" property of the task created by the workflow was not equal with the value of the PBuiltInFieldId._UIVersion property. In the same method we have:

properties.AfterProperties["WorkflowVersion"] = (int) itemById[SPBuiltInFieldId._UIVersion];

This doesn't make too much sense, the workflow version is set to the the ui version of the task item. The UI version is equal with (512 * major version + minor) version and beacuse in the task list we don't have minor versions, then the ui version is 512 * the version number. I created an ItemUpdating event handler on the task list.

For the from workflows not having this problem (receiving the error message above) the event handler was called two times, first time from the due to the postback from the client browser and second time by the workflow persistence job having elevated privileges. For the workflows having the problem, the second call was not done immediatelly, it was done only on any following user postback by submitting or saving an Info Path form attached to any workflow instance. More than that, we had in the workflow an OnTaskChanged Sharepoint Workflow activity, for which the 'invoked' event was not fired. It was very confusing.

The lucky guess
After hours of digging I restored the workflow assemblies to an older version. Suddenly, some workflows started to run!

In the Wofklows table in the Sharepoint content database, each workflow has a corresponding row, and one of the columns contains the serialisation of that workflow, I think it's a binary serialisation and the rule of thumb is that we deployed patches were the new version of the workflow classes didn't have anymore a 100% binary serialisation match with the already running workflows. We didn't had these problems in the test environments because all the worklows were newly created.

Conclusions

  • the message "This task is currently locked by a running workflow and cannot be edited" didn't suggested at all what was the root cause of the problem, it was totally confusing
  • don't apply patches to the workflow assemblies only if you are sure that the binary serialisation will be 100% compatible with the prevoius versions from the workflow assemblies (no attributes are added or removed from classes etc.)
  • leave in the test environment workflows running from previous versions of patches to catch this kind of exceptions
  • if is possible, version you workflows
posted on Saturday, March 01, 2008 2:07 AM

Feedback

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 7/7/2008 2:05 AM Fred Morrison
I have a complex workflow that uses InfoPath forms. I use versioning (change both AssemblyInfo.cs and workflow.xml) when I make changes and always create a new association after deploying the new code. I also reset both SPTimerV3 and IIS, just for good measure.

Versioning doesn't prevent the workflows from becoming "stuck" (DelayActivities don't "pop" when the value of column DeliveryDate in their row in table ScheduledWorkItems in the content database says they should) if I try to run five instances concurrently. Have you ever seen this behavior? I have an open case with Microsoft since June 2, 2008, but have not received an answer other than "a fix is imminent" (no specific date).


# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 7/7/2008 2:35 AM Tibor Molnar
Hi,
we opened too an issue with the Delay activity at Microsoft since month, it behaves unpredictable in workflows hosted in MOSS. The support engineer pointed out a bolog entry on the Sharepoint Team blog which gathered feedback from the community in order to reproduce it.

Please check my blog entry http://geekswithblogs.net/MTex/archive/2007/10/02/115766.aspx , we made a workaround for our specific scenario. Maybe u have something similar. Let me know if this helped.

Cheers,

Tibi

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 7/10/2008 11:45 AM Anonymous Coward
We had problems with the Delay activity until we installed the hotfix from KB932394. We also had problems on our test farm with clocks not being synchronized causing Delay activities to wake up later than expected.

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 10/14/2008 5:03 AM aytekin
Hi,
i have realised that
if (Convert.ToString(task[SPBuiltInFieldId.TaskStatus]) == "Not Started") && Convert.ToString(task[SPBuiltInFieldId.WorkflowVersion]) != "1")
then this error occurs.
I think this is the way of SharePoint to put a lock on a task item.

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 12/24/2008 7:54 PM taskworkflow

Cool Stuff

All the steps are clearly mentioned.

Thanks

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 2/13/2009 8:40 AM Linda
Hi Tibi,

I've been trying to solve this problem for 2 days now but still unsucessful. Could you please tell me how to "restore" the workflow assembly? I appreciate your response.

- Linda

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 7/13/2009 9:36 AM Manuel Cordovil
Hi,

I am having that error too but the problem is that my workflows are from SPD and I do not know how to change their version I got one workflow that in one step goes paralele to 2 users at same time one can complet task the other get this error "This task is currently locked by a running workflow and cannot be edited" this workflow was made in sharepoint desingner.

thanks in advance

Cordovil

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 9/4/2009 12:47 PM Shannon
We have the same issue as Cordovil, we have a step in our workflow that runs the task in Parallel.

First we have one workflow that assigns tasks to as many people as the workflow initiator requests.

Then a second workflow is started when any new task is created. This second workflow has tasks that run in parallel pausing until the due date or waiting for the status to = complete. When the user does submit feedback, the workflow does not mark the task complete but does update the task status field as complete. Also, some of the users who are assigned the task are listed as "Not Started" and when these individuals try to submit feedback they get the "This task is currently locked..." error message.

# re: MOSS workflows: "This task is currently locked by a running workflow and cannot be edited", what the heck? 10/1/2009 2:14 AM Vasudha
Hi,
Even I am facing the same issue as Cordovil. Approval Parallel workflow from SPD is used. Out of mulitple users to whom the tasks are assigned in the workflow only one user is getting the error message "This task is currently locked by a running workflow and cannot be edited".
Thanks in advance.
Vasudha

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: