OptimisticLockingException / DELETE TimerEntity

Hello,
we’re using Camunda 7.8, Spring Boot 2-0.3, and an H2 In-memory database (for testing purpose).
In one of our demo-processes we have an user task with an additional timer entity attached to it.
The timer event is started as soon as the user task is available. if the timer runs out, a listener is triggered to send a notification “task not claimed in time”.

During the last test phase we faced the following problem:

Caused by: org.camunda.bpm.engine.OptimisticLockingException: ENGINE-03005 Execution of ‘DELETE TimerEntity[42101894-feca-11e8-b24a-aa15cb92a510]’ failed. Entity was updated by another transaction concurrently.
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.concurrentUpdateDbEntityException(EnginePersistenceLogger.java:130)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.handleOptimisticLockingException(DbEntityManager.java:406)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.checkFlushResults(DbEntityManager.java:365)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:345)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:314)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:286)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:203)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:132)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:113)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:173)
at com.OURSERVICE.completeTask(…java:273)

Our assumption is:
The above error occured because the user task was completed by an user and at the same point of time the timer event listener was triggered concurrently.

The result was, that the task was completed (no rollback) but the error from above was thrown. Unfortunalety we have additional listeners listening to the completion of the task. These listeners were not invoked due to the exception.
Can you agree with this assumption? Have you ideas to avoid this behaviour? What we want to achieve is

  • either: complete task and trigger additional listeners
  • or: do not complete task (roll back), so that the user can retry.

Thanks and best regards
Roland