cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiOptimisticLockingException on delete from ACT_RU_EXECUTION

nutsnbolts
Champ in-the-making
Champ in-the-making
I am using Activiti 5.12 and am encountering an ActivitiOptimisticLockingException on delete from ACT_RU_EXECUTION. The workflow which I created looks like the "Activiti Definition.txt" The receive task is a just sitting there, so that the timer would fire every 1 minute and kick off the service task which would run for however long it needs to take. There is a static variable within the delegate class of the service object called that will ensure that only 1 instance of the code will be processed at any 1 time.

The cause of the error which I am observing seems to be related to EXECUTION ID 2417310, if you observe the logfile during the time frame of 2014-08-11 00:03:59, activiti has accessed this value and subsequently deleted it from ACT_RU_EXECUTION at 2014-08-11 00:03:59,028. However at 2014-08-11 00:08:16,546 it tries to access the value again, and tries to delete it 1 more time. This causes a rollback in all my transactions which I have been processing during the timeframe. This exception does not seem to happen consistently. Any ideas how I might go about solving this?

Find attached the debug output
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
How many nodes do you have running an engine on? Are all of those job executors?

The error is happening after executing

2014-08-11 00:08:16,538 [pool-2-thread-9] DEBUG behavior.BpmnActivityBehavior  - Leaving activity 'EBSDSServiceTask'

Are there multiple occurences of this step?

nutsnbolts
Champ in-the-making
Champ in-the-making
There is 1 single node running an engine with only 1 executor set to true. In my activi.xml I have a timer "EBSDSTimerEvent" that fires off the task "EBSDSServiceTask" on every 59sec of the minute. In most cases "EBSDSServiceTask" completes whatever task it does in less than a minute. However in rare cases it does take maybe 5 minutes to complete, during which time, the service task would have fired multiple times.

In the service task there I have a static variable in there to ensure that only 1 instance of the code is running.

jbarrez
Star Contributor
Star Contributor
Jobs that take 5 minutes to complete will indeed lead to problems. The default wait time for the job executor is 5 minutes. After 5 minutes, it will deem the job as not executed and hanging.

Two solutions: Make the wait time (or the time until it can be unlocked) longer.
Better is to not have jobs that take 5 mins. Keep in mind you are keeping a db transaction open for 5 minutes! This is never a good idea.
Better is to use some queue mechanism that puts the work on a queue and sends it back to the process once its done.