fix: add supervision strategy support for expand and extrapolate#3185
Open
He-Pin wants to merge 2 commits into
Open
fix: add supervision strategy support for expand and extrapolate#3185He-Pin wants to merge 2 commits into
He-Pin wants to merge 2 commits into
Conversation
Motivation: The expand operator evaluated user-provided expansion logic without consulting SupervisionStrategy, so exceptions failed the stream unconditionally. This also affected extrapolate because it is implemented on top of Expand. Modification: Add supervision handling in Expand for exceptions from the expander function and from iterator evaluation paths (hasNext/next). Stop fails the stage, Resume drops the failed element and continues, and Restart resets extrapolation state before continuing. Update Scala/Java API docs (Flow/Source/SubFlow/SubSource) and operator docs to reflect supervision behavior. Expand docs now explicitly describe Resume vs Restart state semantics. Add directional tests in FlowExpandSpec and FlowExtrapolateSpec for Stop/default Stop/Resume/Restart and iterator-evaluation failures. Result: expand and extrapolate now honor ActorAttributes.SupervisionStrategy for user-function failures, with deterministic regression coverage for exceptional iterator paths. Tests: - sbt "stream-tests/Test/testOnly org.apache.pekko.stream.scaladsl.FlowExpandSpec org.apache.pekko.stream.scaladsl.FlowExtrapolateSpec" -- 23/23 passed - sbt "stream/mimaReportBinaryIssues" -- clean - sbt "docs/paradox" -- passed References: Refs apache#3110
…mantics Motivation: Review of the expand/extrapolate supervision support identified two consistency and documentation gaps. Modification: - Change `private lazy val decider` to `private def decider` in Expand to match the established pattern in Map, Filter, Collect and other fusing operators. - Collapse the Resume and Restart branches in `handleIteratorFailure` since a corrupt iterator must be discarded regardless of the supervision decision, and add a comment explaining why. - Clarify in expand.md that iterator evaluation failures necessarily discard extrapolation state under Resume, while expander-function failures preserve it. Result: Expand's supervision handling is consistent with neighbouring operators and its docs disambiguate the two failure sites. Tests: - sbt "stream-tests/Test/testOnly org.apache.pekko.stream.scaladsl.FlowExpandSpec org.apache.pekko.stream.scaladsl.FlowExtrapolateSpec" (23/23 passed) References: Refs apache#3110
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
Issue #3110 tracks stream operators that should honor
SupervisionStrategyfor user functions.expandcalled the user-provided expansion logic without supervision, so exceptions failed the stream unconditionally. Sinceextrapolateis implemented viaExpand, the same gap applied there too.Modification
Expandfor:hasNext/next)Stop: fail stageResume: drop failed element and continueRestart: drop failed element, reset current extrapolation state, continueFlow,Source,SubFlow,SubSource) to describe supervision behavior and clarify Resume vs Restart forexpand.expand.mdextrapolate.mdFlowExpandSpec: Stop/default Stop/Resume/Restart + iterator-evaluation failure pathsFlowExtrapolateSpec: Stop/Resume/Restart for extrapolator failures during iterator evaluationResult
expandandextrapolatenow honorActorAttributes.SupervisionStrategyfor user-function failures with explicit regression coverage for exceptional iterator paths.which is now Apache licensed
Tests
sbt "stream-tests/Test/testOnly org.apache.pekko.stream.scaladsl.FlowExpandSpec org.apache.pekko.stream.scaladsl.FlowExtrapolateSpec"(23/23 passed)sbt "stream/mimaReportBinaryIssues"(clean)sbt "docs/paradox"(passed)References
Refs #3110