I have trying some performance testing for Camunda.
I had observed following issue under concurrency.
Stacktrace :
--------------------------------------------------------------------------
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 79) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 79) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
at org.camunda.bpm.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation.execute(DbSqlSession.java:264)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:735)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:502)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:155)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:79)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 79) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
.
.
.
.
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 218) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.updateExecution-Inline
### The error occurred while setting parameters
### SQL: update ACT_RU_EXECUTION set REV_ = ?, PROC_DEF_ID_ = ?, ACT_ID_ = ?, ACT_INST_ID_ = ?, IS_ACTIVE_ = ?, IS_CONCURRENT_ = ?, IS_SCOPE_ = ?, IS_EVENT_SCOPE_ = ?, PARENT_ID_ = ?, SUPER_EXEC_ = ?, SUSPENSION_STATE_ = ?, CACHED_ENT_STATE_ = ? where ID_ = ? and REV_ = ?
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 218) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:699)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:500)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:155)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:79)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 218) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
--------------------------------------------------------------------------
I had tried following options to overcome the above issue :
1. Use DBCP Data Source
2. Used BoneCP Data Source
3. Used Atomikos Xa and non XA Datasource
4. Tried with using Jboss DataSource
5. Set READ_COMMITED_TRANSACTION On for SQL Server
6. Used Isolation level - READ_COMMITED , SNAPSHOT etc
The above tryouts performed are on Jetty and Jboss 7.1
In both case we are getting same Exception.
Camunda Versions used are : Camunda 7.0.0-Final / 7.1.0-SNAPSHOT
The Process Enghine Configuration is as follows :
<bean id="processEngineConfiguration"
class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="processEngineName" value="default" />
<property name="dataSource" ref="mssqlDataSource" />
<property name="transactionManager" ref="springTransactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="true" />
<property name="deploymentResources" value="classpath*:*.bpmn" />
<property name="historyEventHandler" ref="ompHistoryEventHandler" />
<property name="history" value="full" />
<property name="jobExecutor" ref="customJobExecutor" />
<property name="idGenerator" ref="strongUuidGenerator" />
</bean>
I had already tried with enabling Row Versioning-Based Isolation Levels and using TRANASACTION_SNAPSHOT
The combo of above index and SNAPSHOT seems to solve the issue.
Also I had disable the SQL Server LOCK ESCALATION for test.
The issues is reproduced .
It seems to be deadlock get reproduced when we add Intermediate Catch Events.
For the Following Process , The issue gets reproduced.
http://camunda.org/share/#/process/1c4f9ae6-379d-4970-b63b-e569a0231c4c
Error while closing command context: org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'dbo.ACT_RU_EVENT_SUBSCR' directly or indirectly in database 'OMPPERF' to update, delete, or insert the row that has been modified or deleted by another transaction. Retry the transaction or change the isolation level for the update/delete statement.
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'dbo.ACT_RU_EVENT_SUBSCR' directly or indirectly in database 'OMPPERF' to update, delete, or insert the row that has been modified or deleted by another transaction. Retry the transaction or change the isolation level for the update/delete statement.
Also here I am trying to start a child Process in Service task S1 , S2 ..
And then from child Process try to signal back.
For Parent Process :
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
processEngine.getRuntimeService().startProcessInstanceByKey(calledSubProcess, props);
The prop contains the Parent Process Id and message Name
For Child Process :
Execution execution =
processEngine.getRuntimeService()
.createExecutionQuery()
.processInstanceId(parent)
.messageEventSubscriptionName(messageName)
.singleResult();
processEngine.getRuntimeService().messageEventReceived(messageName, execution.getId());
Thanks,
Amol
In called process we are releasing the client thread in first task only.
After that just prior to the end event , we signal back to parent process.
I haven't write any test for it. Here we are just deploying our war into camunda - jboss distribution. And using the camunda rest engine. we are using third party client like gatling / standalone code with java tpe to fire Rest API whcih start our parent Process. Here we are firing very high load. Almost around 100 to 1000 threads concurrently.
Meanwhile just to update , we have changed our Process model from Service task delegate + intermediate catch event to Asynchronous Service task + JMS
and from MSSQL side we changed the following setting.
Changed Isolation level from SNAPSHOT to READ_COMMITTED_SNAPSHOT
And Enabled ALLOW_SNAPSHOT_ISOLATION.
We SET LOCK_ESCALATION=DISABLE for every table and added following index
create index ACT_IDX_JOB_EXEC on ACT_RU_JOB(EXECUTION_ID_);
With this setting we haven't received any deadlock for almost 50000 orders test which we fired.
But the DB side CPU seems to be continuously in range of 90-100
Currently we are trying the clustered set up and JMS tuning on Jboss for Camunda. Once done I will re-fire the previous test which gets failed with the above new setting and will post the result.
Thanks,
Amol Walanj
org.camunda.bpm.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
at org.camunda.bpm.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation.execute(DbSqlSession.java:252)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:723)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:490)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:196)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:126)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:99)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:79)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource
I note that one of my test processes uses an intermediate throw event in the middle of a parallel process construct. This looks very similar to the example from this thread. Perhaps there's a link...
I'll try again to narrow down further...
regards
Rob