The process engine does not run the exclusive tasks with the same java thread

According to the flowable documentation, the exclusive tasks of a process instance all run sequentially through the same thread, or that is what I can understand.
I put an excerpt from the documentation:

‘What are exclusive jobs?
An exclusive job cannot be performed at the same time as another exclusive job from the same process instance.
Consider the process shown above: if we declare the service tasks to be exclusive, the JobExecutor will make sure that the corresponding jobs are not executed concurrently.
Instead, it will make sure that whenever it acquires an exclusive job from a certain process instance, it acquires all other exclusive jobs from the same process instance and delegate them to the same worker thread.
This ensures sequential execution of the jobs.’

I send you an image of our flow, the ‘ExclusiveTimer’ and ‘ExclusiveTask’ tasks are exclusive tasks and are not running in the same java thread

What would be the necessary configuration for my process engine to work as the documentation says?

No, that’s not correct. Exclusive means that at no point in time two activities of the same process instance will be running. The docs are incorrect there (this was the case a very long time ago, but not anymore for scalability reasons), I will update this.

ExclusiveTimer task is exclusive and asynchronous, and simulates a runtime of 15 seconds
the Timer task is asynchronous, and simulates a runtime of 5 seconds
ExclusiveTask task is exclusive, expects nothing and goes to the next step
pg-2 parallel gwy is asynchronous

I see that the ExclusiveTimer and ExclusiveTask tasks are processed at the same time, what’s more, the parallel gwy is reached first by the ExclusiveTask task path
I also notice, and is more puzzling, that exceptions occur when parallel gwy is processed, I expected an exception to occur earlier:

org.apache.ibatis.exceptions.PersistenceException:

Error updating database. Cause: org.h2.jdbc.JdbcSQLTimeoutException: Tiempo vencido intentando trabar (lock) la tabla {0}

Timeout trying to lock table {0}; SQL statement:
update ACT_RU_EXECUTION
SET REV_ = ?
where ID_ = ?
and REV_ = ? [50200-200]

The error may exist in org/flowable/db/mapping/entity/Execution.xml

The error may involve org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.updateExecution-Inline

The error occurred while setting parameters

SQL: update ACT_RU_EXECUTION SET REV_ = ? where ID_ = ? and REV_ = ?

Cause: org.h2.jdbc.JdbcSQLTimeoutException: Tiempo vencido intentando trabar (lock) la tabla {0}

Timeout trying to lock table {0}; SQL statement:
update ACT_RU_EXECUTION
SET REV_ = ?
where ID_ = ?
and REV_ = ? [50200-200]
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[mybatis-3.5.1.jar:3.5.1]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199) ~[mybatis-3.5.1.jar:3.5.1]
at org.flowable.common.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:503) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:292) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:191) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.interceptor.CommandContext.close(CommandContext.java:61) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:81) [flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:56) [flowable-spring-common-6.4.2.jar:6.4.2]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:56) [flowable-spring-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51) ~[flowable-engine-common-6.4.2.jar:6.4.2]
at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:128) ~[classes/:na]
at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:116) ~[classes/:na]
at flowable.testings.config.flowable_mq.JobMessageListener.onMessage(JobMessageListener.java:37) ~[classes/:na]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:761) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:699) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:674) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:318) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:257) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1189) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076) ~[spring-jms-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_101]
Caused by: org.h2.jdbc.JdbcSQLTimeoutException: Tiempo vencido intentando trabar (lock) la tabla {0}
Timeout trying to lock table {0}; SQL statement:
update ACT_RU_EXECUTION
SET REV_ = ?
where ID_ = ?
and REV_ = ? [50200-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:511) ~[h2-1.4.200.jar:1.4.200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200]
at org.h2.message.DbException.get(DbException.java:194) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Command.filterConcurrentUpdate(Command.java:309) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Command.executeUpdate(Command.java:253) ~[h2-1.4.200.jar:1.4.200]
at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:240) ~[h2-1.4.200.jar:1.4.200]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-3.4.2.jar:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) ~[HikariCP-3.4.2.jar:na]
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.1.jar:3.5.1]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.1.jar:3.5.1]
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.1.jar:3.5.1]
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.1.jar:3.5.1]
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.1.jar:3.5.1]
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.1.jar:3.5.1]
… 23 common frames omitted
Caused by: org.h2.message.DbException: Actualización concurrente sobre la tabla “ACT_RU_EXECUTION”: otra transacción ha actualizado ó borrado la misma fila
Concurrent update in table “ACT_RU_EXECUTION”: another transaction has updated or deleted the same row [90131-200]
at org.h2.message.DbException.get(DbException.java:194) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.db.MVTable.convertException(MVTable.java:707) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.db.MVPrimaryIndex.lockRow(MVPrimaryIndex.java:232) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.db.MVPrimaryIndex.lockRow(MVPrimaryIndex.java:224) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.db.MVTable.lockRow(MVTable.java:567) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.dml.Update.update(Update.java:144) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.CommandContainer.update(CommandContainer.java:198) ~[h2-1.4.200.jar:1.4.200]
at org.h2.command.Command.executeUpdate(Command.java:251) ~[h2-1.4.200.jar:1.4.200]
… 32 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLTransientException: Actualización concurrente sobre la tabla “ACT_RU_EXECUTION”: otra transacción ha actualizado ó borrado la misma fila
Concurrent update in table “ACT_RU_EXECUTION”: another transaction has updated or deleted the same row [90131-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:626) ~[h2-1.4.200.jar:1.4.200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200]
… 40 common frames omitted
Caused by: java.lang.IllegalStateException: Map entry <table.116> with key <1> and value [‘71f0b54d-6b1f-11ea-961e-dc85de1cc6ec’, 1, ‘71f0b54d-6b1f-11ea-961e-dc85de1cc6ec’, NULL, NULL, ‘exclusives_test:1:6d954a66-6b1f-11ea-961e-dc85de1cc6ec’, NULL, ‘71f0b54d-6b1f-11ea-961e-dc85de1cc6ec’, NULL, TRUE, FALSE, TRUE, FALSE, FALSE, 1, NULL, ‘’, NULL, ‘start-event-first’, TIMESTAMP ‘2020-03-20 23:55:38.798’, NULL, NULL, TRUE, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL] 3/9 [‘71f0b54d-6b1f-11ea-961e-dc85de1cc6ec’, 1, ‘71f0b54d-6b1f-11ea-961e-dc85de1cc6ec’, NULL, NULL, ‘exclusives_test:1:6d954a66-6b1f-11ea-961e-dc85de1cc6ec’, NULL, ‘71f0b54d-6b1f-11ea-961e-dc85de1cc6ec’, NULL, TRUE, FALSE, TRUE, FALSE, FALSE, 1, NULL, ‘’, NULL, ‘start-event-first’, TIMESTAMP ‘2020-03-20 23:55:38.798’, NULL, TIMESTAMP ‘2020-03-21 00:00:38.944’, TRUE, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL] is locked by tx 3 and can not be updated by tx 1 within allocated time interval 2000 ms. [1.4.200/101]
at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:950) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.tx.TransactionMap.set(TransactionMap.java:316) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.tx.TransactionMap.lock(TransactionMap.java:263) ~[h2-1.4.200.jar:1.4.200]
at org.h2.mvstore.db.MVPrimaryIndex.lockRow(MVPrimaryIndex.java:230) ~[h2-1.4.200.jar:1.4.200]
… 37 common frames omitted