Unexpected rollback exception


iot_create_order.bpmn (7.9 KB)

I am running process instance desribed in image above. As you can see, there is error boundary event in activity “Call 3rd Party”, that catches BPMN error with any code and execute activity “Cancel Order”

In activity Call 3rd party I am creating synchronous sub-process in code, and if it’s fail, I throw BPMN error to trigger “Cancel Order” activity.
The code looks like this

           Try.run(() -> {
           startThirdPartyProcess(accountConfiguration, order, tenant);
       }).onFailure(e -> {
           log.error("Error occurred during third party action, cause: ", e);
           throw new BpmnError("ThirdPartyError");
       });

Then I create process, which should fail at activity “Call 3rd party” and then “Cancel Order” should be executed. But instead, there is error in stack trace

2020-09-02 12:53:51.343 ERROR 17072 --- [aTaskExecutor-1] c.t.c.p.c.i.c.a.CallThirdPartyAction     : Error occurred during third party action, cause: 

org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script while executing activity 'Activity_0eec1p3' in the process definition with id 'iot_call_third_party_TMA:1:31a1dc39-ed02-11ea-9fa0-00ff6821bc2f': org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [{"code": 500, "message": "Internal server error"}]
	at org.camunda.bpm.engine.impl.scripting.CompiledExecutableScript.evaluate(CompiledExecutableScript.java:61) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:61) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:63) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:101) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:87) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:47) ~[camunda-engine-7.12.0.jar:7.12.0]

And then

    2020-09-02 12:53:51.531  WARN 17072 --- [aTaskExecutor-1] o.c.b.e.jobexecutor                      : ENGINE-14006 Exception while executing job 328bee37-ed02-11ea-9fa0-00ff6821bc2f: 

    org.springframework.transaction.UnexpectedRollbackException: Transaction silently rolled back because it has been marked as rollback-only
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:752) ~[spring-tx-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) ~[spring-tx-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:152) ~[spring-tx-5.2.5.RELEASE.jar:5.2.5.RELEASE]
	at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:44) ~[camunda-engine-spring-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:57) ~[camunda-engine-7.12.0.jar:7.12.0]
	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:71) [camunda-engine-7.12.0.jar:7.12.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]

And activity “Call 3rd party” try to retry (like it was technical, not BPMN error)

Could you help me what I’ve done wrong?

Hi @Dmitriy_Stoyanov

Can you take a look a the style guide and format your post to make it easier to read?
Can you also upload your model? Seeing the technical details of the model can be very useful

-Niall

HI @Niall
I’ve edited post and add bmpn file

Thanks a lot for editing your post :slight_smile:

Does the same error happen if you surround the method with a try catch instead?

try{
          startThirdPartyProcess(accountConfiguration, order, tenant);
}catch(Exception e){
           log.error("Error occurred during third party action, cause: ", e);
           throw new BpmnError("ThirdPartyError");
}

Seems from the log that the error isn’t being caught.

No, it doesn’t help. Try.run of io.vavr is the same as try-catch block

@Niall Hello. Do you have any other idea why this error can be caused?

Is anybody here?

Hi @Dmitriy_Stoyanov

I wasn’t able to replicate the problem so i’m not sure what to suggest. If you can create an example project which fails this way i’ll take a look and try to work out what might be causing it.

Hi, @Niall.
I create example application - https://github.com/DimaStoyanov/CamundaBPMNError and reproduces the same error.
Maybe my error caused by mysql settings? We have MySql 5.6.30-log version in our envrionment and also I’m not sure mysql support inner transaction, which maybe need for camunda (create subprocess)

Are you using correct isolation level?
https://docs.camunda.org/manual/latest/user-guide/process-engine/database/#isolation-level-configuration

We have REPEATABLE-READ level. You think it’s the reason of error?
I’m not sure it’s easy for us to change isolation level, because it’s db level property and it will affect many services

Well it could be - because we only support READ COMMITTED as the isolation error.

Hi, @Niall
I tried this process with postgreSQL which has READ_COMMITTED as default and this does not help. I still get error about read-only transaction.

For me it looks like bug in Camunda engine or maybe you have another idea why this error happening?