Weird exception when setting variable in Async Task

Hi, Folks,

I am testing true async task execution and error handling in such parallel tasks.
What i have is a simple parallel async tasks, 1 of which throws BPMN Error and the other “Does something for X milliseconds” and sets variable in the context.
The problem I have is that the whole test crashes with “Referential integrity constraint violation…” in mybatis engine.

I suspect the issue is that, since both tasks are executed in true async manner, the whole process have completed before the second task have completed. And tries to write in context of already completed process. However the exception is completely weird and happens in the main thread.

First question is:

  1. What happens if we run a parallel true async tasks (one of them fails with BPMNError , while other continue) and try to write in the context.
  2. Can I handle this more gracefully? Since it seems the main thread running the process crashes with the mentioned exception

Best Regards, Chavdar

Here is the process:
Flowable Error

[UPDATE] It seems solution i found is to check if the execution is active before setting anything into the context. Could someone let me know if this is the correct approach ?
Basically I am concluding is that, the SimpleService Task 2 is trying to set a variable in process after the process have ended (through the MBPN error).

default void afterExecution(DelegateExecution execution, E output) {
if (!execution.isActive()) {
// Can not set variables on inactive execution
return;
}
execution.setVariable…
}