cancel
Showing results for 
Search instead for 
Did you mean: 

Inability to Completely Delete a Process Instance When...

ryanj1
Champ in-the-making
Champ in-the-making
…a Service Task that is executed via the Job Executor fails *and*:

(1) There is an Error Boundary Event configured on the Service Task and
(2) The failure is not a BpmnError instance with an "errorCode" that matches the one configured in the Error Boundary Event. (Obviously, if this occurs, the process instance would continue along the Error Boundary Event's subsequent path. Just providing this to paint a complete picture. Smiley Happy )

When I say that the process instance isn't completely deleted, I specifically mean that no END_TIME_ has been updated into the record in the ACT_HI_PROCINST table.

Admittedly, this is a corner case, but it has caused some problems at my current client.

I haven't had the time to trace all the way through the code and chase this down, but I'd be happy to make and test the necessary modification(s)… My hope is that one of the core developers can point me in the right direction of where this issue might be within the code base. (Or perhaps one of the core developers is saying "aha" as they're reading this and know right where to go to fix it? Smiley Happy )

Thanks in advance.
6 REPLIES 6

trademak
Star Contributor
Star Contributor
Hi Ryan,

Do you mean that a job is retried 3 times and that it stays in failed state? So the process instance is not ended, but waiting for a manual retry of the job. Is this the issue you are running into?

Best regards,

ryanj1
Champ in-the-making
Champ in-the-making
Correct. The difference is that the delete operation doesn't update the END_TIME_ field (in the ACT_HI_PROCINST table) for the process instance in the scenario described above, whereas that same delete operation *does* update the END_TIME_ field in all other observed scenarios. For clarity, note that "all other observed scenarios" includes scenarios where the associated job fails three times but there is no Error Boundary Event configured on the Java Service Task. 

jbarrez
Star Contributor
Star Contributor
Hmm, looks like a subtle bug.
Do you have a unit test that demonstrates this problem - then we can fix it.

ryanj1
Champ in-the-making
Champ in-the-making
Joram,

Sorry for the delay. I'm attaching four files; those are:

(1) The JUnit test (DemoPartialDeletion.java)
(2) The BPMN (DemoPartialDeletion.bpmn)
(3) The (very simple) engine configuration (activiti-basicinmemwithje.xml)
(4) The Java class used to throw the BpmnError instance (ThrowBpmnError.java)

(To get around the Forum's upload limitations, I've appended "*.txt" to all four files.)

This will demonstrate that deleting a process instance that meets the corner case criteria outlined earlier in this thread can't be fully deleted. Note that this does cause problems in Activiti Explorer as well, as the process instance is partially deleted, resulting in an inability to display the instance when selected on the "My Instances" page.

If you have additional questions, please don't hesitate to let me know.

-Ryan

jbarrez
Star Contributor
Star Contributor
Hi Ryan,

Many thanks for this excellent unit test. Really high-quality and usefull.

Indeed, you hit an edge case bug. Even better, it's a bug introduced FOUR years ago.
It happens when you delete a process instance when the current activity is a scope. In your case, the service task is a scope due to the error boundary event.

It took us quite a bit of very deep debugging …. but we fixed it! See https://github.com/Activiti/Activiti/commit/95506994dc71d090aca67557bc017ad674436dd0

Many thanks. This is open source power at work!

ryanj1
Champ in-the-making
Champ in-the-making
You're very welcome. Yes, this is open source power at work, and I'm very happy to be a part of this open source project, both from a personal perspective and now as a team member at BP3.