eatmoreduck opened a new pull request, #7278:
URL: https://github.com/apache/incubator-kie/pull/7278

   **Thank you for submitting this pull request**
   
   **NOTE!:** Target branch is `main`.
   
   **Issue**:
   
   * 
[apache/incubator-kie#7274](https://github.com/apache/incubator-kie/issues/7274)
   
   **Referenced Pull Requests**: _(none)_
   
   ---
   
   ## What
   
   A manual instance-level error retry (`ProcessInstanceRetry` / 
`ProcessError.retrigger`) on a failed async service task leaves the process 
ACTIVE forever: the retry executes the service again and reaches the end node, 
but the persisted `AsyncEventNodeInstance` wrapper — whose instance id differs 
from the work-item instance id recorded in the error and is gone after the 
rollback anyway — is never cancelled, so the node-instance collection never 
empties. The reporter confirmed the wrapper still references its original ERROR 
job.
   
   ## Root cause
   
   `ProcessError.retrigger` (AbstractProcessInstance) cancels only the node 
instance recorded in the error. For an async node, that record points at the 
real work-item instance; the wrapper that a persisted restore resolves for the 
same node has its own id, so nothing cancels it, and the retried execution goes 
through a fresh wrapper resolved by `getByNodeDefinitionId`.
   
   ## Fix
   
   Before retriggering the node definition, the retry now cancels every *other* 
pending `AsyncEventNodeInstance` in the process's node-instance collection — 
`AsyncEventNodeInstance.cancel` also cancels the job it still references, so 
the ERROR job from the exhausted automatic retries is cleaned up too.
   
   The same gap exists on the node-level `retriggerNodeInstance` path discussed 
in the issue (it triggers the actual node directly, bypassing the wrapper's own 
completion cleanup); that path is not addressed here to keep this fix scoped to 
the reported instance-level retry.
   
   ## Tests
   
   `AbstractProcessInstanceTest.retriggerCancelsStaleAsyncWrapper` — a 
mock-level regression test at the `ProcessError` layer: internal instance in 
ERROR whose recorded instance id resolves to nothing, a stale async wrapper in 
the node collection, and a fresh instance resolved by definition. **Red on 
main** (the wrapper is never cancelled), green with the fix: the wrapper is 
cancelled and the definition is retriggered.
   
   Full `jbpm-flow` module: 232 tests, 0 failures.
   
   <details>
   <summary>How to replicate the CI locally</summary>
   
   `mvn -pl kogito-jbpm/jbpm-flow -am test`
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to