AnsweredAssumed Answered

SQL Deadlock

Question asked by pault on Dec 29, 2010
Latest reply on Jan 6, 2011 by jbarrez
I am hitting a deadlock at a point where 2 threads start processes in quick succession. 9 times out of 10 it is fine, but on occasions I get the deadlock below.

It looks like one thread is starting a process while another is setting variables? I guess I am doing something wrong, any pointers on what that might be based on the error ?

org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Deadlock detected. The current transaction was rolled back. Details: "
Session #13 (user: SA) is waiting to lock PUBLIC.ACT_HI_ACTINST while locking PUBLIC.ACT_RU_EXECUTION (exclusive), PUBLIC.ACT_HI_PROCINST (exclusive), PUBLIC.ACT_RU_VARIABLE (exclusive), PUBLIC.ACT_GE_BYTEARRAY (exclusive).
Session #9 (user: SA) is waiting to lock PUBLIC.ACT_RU_EXECUTION while locking PUBLIC.ACT_HI_ACTINST (exclusive)."; SQL statement:
insert into ACT_RU_EXECUTION (ID_, REV_, PROC_INST_ID_, BUSINESS_KEY_, PROC_DEF_ID_, ACT_ID_, IS_ACTIVE_, IS_CONCURRENT_, IS_SCOPE_, PARENT_ID_, SUPER_EXEC_)
    values (
      ?,
      1,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?
    ) [40001-132]
### The error may involve org.activiti.persistence.insertExecution-Inline
### The error occurred while setting parameters
### Cause: org.h2.jdbc.JdbcSQLException: Deadlock detected. The current transaction was rolled back. Details: "
Session #13 (user: SA) is waiting to lock PUBLIC.ACT_HI_ACTINST while locking PUBLIC.ACT_RU_EXECUTION (exclusive), PUBLIC.ACT_HI_PROCINST (exclusive), PUBLIC.ACT_RU_VARIABLE (exclusive), PUBLIC.ACT_GE_BYTEARRAY (exclusive).
Session #9 (user: SA) is waiting to lock PUBLIC.ACT_RU_EXECUTION while locking PUBLIC.ACT_HI_ACTINST (exclusive)."; SQL statement:
insert into ACT_RU_EXECUTION (ID_, REV_, PROC_INST_ID_, BUSINESS_KEY_, PROC_DEF_ID_, ACT_ID_, IS_ACTIVE_, IS_CONCURRENT_, IS_SCOPE_, PARENT_ID_, SUPER_EXEC_)
    values (
      ?,
      1,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?,
      ?
    ) [40001-132]

Outcomes