Deadlock when running 2 instances


I’m testing my springboot application with a flowable process engine embedded.
I’m running 2 instances of the application against the same database.

I’m testing a simple flow:

  • Send event to rabbitmq for starting the process (startEvent+3 variables)
  • Then the flow waits on a User Task
  • User task has a boundary event - breakEvent
  • When I send the breakEvent - my flow sends a new startEvent to rabbitmq and arrives at the end of the process (so current process is finished - and new process instance is activated)

This works fine both when running a single instance of my application - and when running the 2 instances.
But - in some runs - after sending the breakEvent - i can see one of the servers receiving the startEvent - but getting a Deadlock exception on “INSERT INTO ACT_RU_VARIABLE”
after it rolls-back the transaction - the second message receives the event from the queue and processes it ok.

Reading the log of both servers and comparing the times - i suspect that this happens when the new startEvent arrives to the server - before the other server finished deleting the variables of the previously running instance.

What should be the solution for that ?


Which database are you using? This sounds like a case that the database should be able to handle with the rollback only (throwing an optimistic locking exception).

I am using MariaDB.
And i’m able to reproduce this error many time (although it does not happen on each process execution)