AnsweredAssumed Answered

A dead lock occurred on ACT_HI_ACTINST

Question asked by william.thierry on Aug 29, 2016
Latest reply on Sep 12, 2016 by william.thierry

We are currently facing deadlock on ACT_HI_ACTINST on full asynchronous/exclusive node processes

org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable Job 1169985 failed
### Error querying database.  Cause: Transaction (Process ID 270) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
To summarize on what happened:
1. 2 jobs of notification are inserted in ACT_RU_JOB. The jobs are created and the transactions are commited .
2. The job concerning PID=1168762 (exec=1181856) is executed firstly and the subwokflow is terminated so the engine is updating ACT_HI_ACTINST to set an endtime "2016-08-25 15:36:15"
update ACT_HI_ACTINST set
      EXECUTION_ID_ = @P0,
      ASSIGNEE_ = @P1,
      END_TIME_ = @P2,
      DURATION_ = @P3
    where ID_ = @P4',4112,8193,@p7 output,N'1181856',NULL,'2016-08-25 15:36:15.0620000',50805,N'1181857'
select @p1, @p2, @p7
3. The job concerning PID=1181910 (exec=1181952) is executed and tries to query ACT_HI_ACTINST with a simple select (after 15:35:44 date of creation of the event)
select RES.* , row_number() over (ORDER BY RES.ID_ asc) rnk FROM ( select distinct RES.*
        and RES.ACT_ID_ = @P1
        and RES.END_TIME_ is null
    )RES ) SUB WHERE SUB.rnk >= @P2 AND SUB.rnk < @P3',4112,8193,@p7 output,N'1181952',N'messageintermediatecatchevent4',1,2
4. A deadlock is detected between the select and the update and the exec=1181952 is killed
5. the event notification job=1169985 is in error and the workflow is stuck on the node