Signal catching event triggers more than one thread

Hi,

I am facing a situation that i don’t understand. Hope someone can help me.

I have a process in which i have defined a signal catching event.

When this catcher triggers the process continues. The signal is updated as follows:

runtimeService.signalEventReceivedAsync(SIGNAL, execution.getId());

It appears to work correctly but i found a problem. Before the process ends (and therefore its transaction ends) another process is triggered, from the same signal catcher, in another thread.

In the end, both executions fail with a FlowableOptimisticLockingException.

I don’t understand why the catcher triggers two differents thread for the same process/job. Is this a normal behaviour? Any ideas?

Here are the errors:

“ERROR”,“msg”:“Job 858330 failed”,“exception”:{“thread”:“SimpleAsyncTaskExecutor-1860”,“process”:33,“stacktrace”:{“exception”:“org.flowable.engine.common.api.FlowableOptimisticLockingException”,“cause”:“JobEntity [id=858330] was updated by another transaction concurrently”,“extendedStacktrace”:“org.flowable.engine.common.api.FlowableOptimisticLockingException: JobEntity [id=858330] was updated by another transaction concurrently\n\tat org.flowable.engine.common.impl.db.DbSqlSession.flushDeleteEntities(DbSqlSession.java:561)\n\tat org.flowable.engine.common.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:522)\n\tat org.flowable.engine.common.impl.db.DbSqlSession.flush(DbSqlSession.java:293)\n\tat org.flowable.engine.common.impl.interceptor.CommandContext.flushSessions(CommandContext.java:193)\n\tat org.flowable.engine.common.impl.interceptor.CommandContext.close(CommandContext.java:63)\n\tat org.flowable.engine.common.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:81)\n\tat org.flowable.idm.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:49)\n\tat org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)\n\tat org.flowable.idm.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:46)\n\tat org.flowable.engine.common.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)\n\tat org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)\n\tat org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)\n\tat org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:125)\n\tat org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:112)\n\tat java.lang.Thread.run(Thread.java:748)\n”}}},

“ERROR”,“msg”:“Job 858330 failed”,“exception”:{“thread”:“SimpleAsyncTaskExecutor-1861”,“process”:33,“stacktrace”:{“exception”:“org.flowable.engine.common.api.FlowableOptimisticLockingException”,“cause”:“JobEntity [id=858330] was updated by another transaction concurrently”,“extendedStacktrace”:“org.flowable.engine.common.api.FlowableOptimisticLockingException: JobEntity [id=858330] was updated by another transaction concurrently\n\tat org.flowable.engine.common.impl.db.DbSqlSession.flushDeleteEntities(DbSqlSession.java:561)\n\tat org.flowable.engine.common.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:522)\n\tat org.flowable.engine.common.impl.db.DbSqlSession.flush(DbSqlSession.java:293)\n\tat org.flowable.engine.common.impl.interceptor.CommandContext.flushSessions(CommandContext.java:193)\n\tat org.flowable.engine.common.impl.interceptor.CommandContext.close(CommandContext.java:63)\n\tat org.flowable.engine.common.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:81)\n\tat org.flowable.idm.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:49)\n\tat org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)\n\tat org.flowable.idm.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:46)\n\tat org.flowable.engine.common.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)\n\tat org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)\n\tat org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)\n\tat org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:125)\n\tat org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:112)\n\tat java.lang.Thread.run(Thread.java:748)\n”}}},

;

Hi,

Your use case can be described by the test https://github.com/flowable/flowable-engine/blob/a8a0fc69fb1e0bcacfa8644cb2bcffd8977a5b59/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/event/signal/SignalEventTest.java#L355

Can you provide a jUnit test to reproduce the issue?

mvn archetype:generate -DarchetypeGroupId=org.flowable -DarchetypeArtifactId=flowable-archetype-unittest -DarchetypeVersion=6.4.1

Regards
Martin