Repository navigation
fix: run stage cleanup when postStop throws - #3814
Merged
He-Pin merged 1 commit intoNov 29, 2026
Merged
Conversation
pjfanning
reviewed
Nov 26, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Looks good to me. Skipping afterPostStop also left the stage actor running, substreams not cleaned up and the timers of a TimerGraphStageLogic not cancelled, so this fixes more than the pending callback feedback. One optional nit inline.
Motivation: A non-fatal stage postStop exception should not skip internal cleanup, including pending callback feedback. Modification: Catch non-fatal stage stop and cleanup failures separately. Keep the existing postStop log and give cleanup failures their own message, preserving the original cause in either case. Result: Internal cleanup still runs, the two errors are distinguishable, and normal downstream termination is unchanged. Fatal errors still escape. Tests: JDK 17, Scala 2.13.18 and 3.3.9. Focused interpreter lifecycle and failure-mode suites, including a manually stepped cleanup-log assertion and the existing pending-feedback regression. References: PJ's review on apache#3814; apache#3409 covers watched sinks.
He-Pin
force-pushed
the
fix/stream-cleanup-after-poststop-failure
branch
from
November 26, 2026 12:59
341cbea to
9d83dd0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
If a local GraphStage
postStophook throws a non-fatal exception, the interpreter skips its internalafterPostStophook. In particular, a pending asynchronous callback can miss the notification that its stage has detached.Modification
Handle non-fatal failures from the two stop hooks separately, so internal cleanup runs even if the user hook fails. Keep the existing error log and original cause, preserve stream termination behavior, and continue to let fatal exceptions escape.
Result
A failed local stop hook no longer prevents the interpreter from cleaning up the stage. No public API changes.
Tests
invokeWithFeedbackresult, the unchanged downstream completion signal, and one call to each stop hook. It failed on the old implementation and passed with the fix.+headerCheckAllpassed locally.References
Related to #3409, which handles watched sinks. This change covers ordinary stages independently.