zzwqqq opened a new pull request, #1509:
URL: https://github.com/apache/flink-agents/pull/1509

   <!--
   * Thank you very much for contributing to Flink Agents.
   * Please add the relevant components in the PR title. E.g., [api], 
[runtime], [java], [python], [hotfix], etc.
   -->
   
   <!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this. 
-->
   Linked issue: #1322
   
   ### Purpose of change
   
   <!-- What is the purpose of this change? -->
   When a member's cancel hook threw, the group skipped later handles. An 
Action could catch the error and still fail at finalization because those 
handles were pending.
   #### Runtime flow
   `group.cancel()` calls `cancel()` on each handle. If preparation aborts a 
group wait, `gather` tries to cancel each unfinished call, then closes the 
group's handles.
   
   #### Key decisions
   Java uses `firstOrSuppressed` because a cancel hook can throw the original 
exception again. Calling `addSuppressed` with that same exception would mask 
it. Python reuses the scheduler's cleanup helper.
   
   ### Behavioral Semantics
   
   <!-- For a non-trivial code change whose implementation is largely 
AI-assisted: interaction decisions, behavioral contracts, and failure behavior. 
See `contribution-guides/ai-assisted-pr.md`. Remove this heading and this 
comment otherwise. -->
   #### Interaction decisions
   
   | When cleanup fails | What the caller sees |
   | --- | --- |
   | During `group.cancel()` | The first cancellation error, after the last 
cancellation attempt |
   | After preparation aborts a group wait | The original preparation error |
   
   #### Behavioral contracts
   
   A built-in handle is removed from the Action's pending calls even if its 
remote cancel hook throws.
   
   #### Failure behavior
   
   Java attaches later distinct errors as suppressed exceptions. Python logs 
later cleanup errors.
   
   ### Tests
   
   <!-- How is this change verified? -->
   | Behavior under test | Java / Python regression tests |
   | --- | --- |
   | A third member gets a cancel request even after the first two hooks throw 
| `groupCancelAttemptsEveryMemberAfterFailure` / 
`test_group_cancel_attempts_every_member_after_failure` |
   | A group wait preserves the preparation exception when a cancel hook throws 
it again | `groupAwaitPreservesPreparationFailureDuringCleanup` / 
`test_group_await_preserves_preparation_failure_during_cleanup` |
   
   The Java tests run the Action in a Flink operator harness. The Python tests 
call its finalization hook directly. Both suites simulate the remote calls.
   
   <details>
   <summary>Local verification</summary>
   
   The Java runtime tests passed on JDK 21 and the Python unit suite passed on 
Python 3.11. Both new Java tests also passed on JDK 17.
   
   </details>
   
   ### API
   
   <!-- Does this change touches any public APIs? -->
   No public API signature changes.
   ### Documentation
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [ ] `doc-needed` <!-- Your PR changes impact docs -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [x] `doc-included` <!-- Your PR already contains the necessary 
documentation updates -->
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Codex 0.171 (gpt-6.2)
   


-- 
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]

Reply via email to