Workflow with a long processing time stopping abruptly with the message - "Failed on Start (Retrying)"

Recently I was working on a SharePoint Workflow issue. The workflow had just two activities in it - The WorkFlowActivated activity & The CodeActivity activity. The WorkFlowActivated activity had normal stuff - activating certain workflow variables (Normal Stuff). The CodeActivity activity had a huge code base (around 3000 lines and 10 private methods). The code in the code activity involves - reading the added item's field value and then does a lot of calculations and then creates items into a new list. The items written to the list range from 300 to 10000. The workflow worked perfectly if the items to be written were below 1200. Just as the workflow items increased from 1200, the workflow stopped after writing 1200 items and the status of the workflow showed as "Failed on Start (Retrying)". The workflow used to take anything beyond 3 minutes to complete. (Took arnd 5 mins to write 1200 items)

So I started analyzing the code (in the CodeActivity activity) , but as such nothing noteworthy was found. Since the workflow is a long duration workflow, I thought probably one should check the property associated with the workflow - WorkFlowTimeOut property. By default this property's value is 5 mins. If a workflow is taking more than 5 mins to complete, the workflow would stop after 5 mins.

So I simply increased the WorkFlowTimeOut property's value to 30 mins using the stsadm command:

Stsadm –o setproperty –pn workflow-eventdelivery-timeout –pv 30

And Voila! this worked. This property is a cool property to check whenever you have workflow's which have a lot of processing and normally run for more than 5 mins.

You can read about this command at the following link:

https://technet.microsoft.com/en-us/library/cc288917(TechNet.10).aspx