The exception is thrown at runtimeService.deleteProcessInstance (pId, null);.
Yes, tasks are asynchronous. The model is a trivial example to showcase this behaviour. One ServiceTask between Start and End events. The task is a Java class simply doing a sleep ().
I can share the full set of files. What’s the preferred way to do this here?
Hello,
Same problem with test case reported in this existing GitHub issue (considering that if we are not able to stop a running workflow it can be considered as a bug, no? ;))
The suspend fails because Flowable uses optimistic locking (and only one database transaction can win). This is why it only works when in a wait state. And even then, which transaction will win is random (determined by the database). An instance can only be deleted/suspended when it’s not executing anything else at that moment. The only alternative I see is an async job that would retry on failure and eventually will succeed.
The mechanism in itself is understood. The question is: Is there a way to successfully terminate a running process. Looks like this is not the case. I guess it’s somewhat hard as there is no safe way to stop the async executor’s threads.
Looks like we are left with implementing some cancel functionality in the process itself or wait until it terminates peacefully.
But considering that such delete may be more or less impossible in some cases (e.g. when there’s always a task in progress), wouldn’t it be possible to mark in addition a workflow as “candidate for deletion”?
When starting the delete, this flag could be set (to the execution like the SUSPENDED flag?); if the delete succeeds, everything is deleted, but if it fails we have at least this information which could be used later by Flowable (or even by the workflow) to stop its execution.