Skip to content

fix(stream): preserve abrupt fanout publisher shutdown signal#2910

Merged
He-Pin merged 1 commit intoapache:mainfrom
He-Pin:fix-fanout-publisher-abrupt-poststop
Apr 26, 2026
Merged

fix(stream): preserve abrupt fanout publisher shutdown signal#2910
He-Pin merged 1 commit intoapache:mainfrom
He-Pin:fix-fanout-publisher-abrupt-poststop

Conversation

@He-Pin
Copy link
Copy Markdown
Member

@He-Pin He-Pin commented Apr 25, 2026

Motivation

FanoutPublisherBridgeStage.postStop always completed the exposed publisher with ActorPublisher.NormalShutdownReason, even when the stage was stopped abruptly without an upstream or subscriber terminal signal. That made active and late subscribers observe a normal shutdown instead of the GraphStage abrupt termination failure.

Modification

Track whether the bridge is stopping from an intentional terminal path. Only synthesize AbruptStageTerminationException from postStop when no terminal path was already signalled, and add a bridge-level regression test for active and late subscribers.

Result

Controlled completion, failure, timeout, and last-subscriber cancellation keep their existing reasons, while abrupt bridge shutdown is now reported as AbruptStageTerminationException.

Tests

  • sbt "stream-tests/testOnly org.apache.pekko.stream.impl.FanoutPublisherBehaviorSpec"
  • sbt "stream-tests-tck/testOnly org.apache.pekko.stream.tck.FanoutPublisherTest"
  • sbt "stream / Compile / scalafmtCheck" "stream-tests / Test / scalafmtCheck"

References

#2874

Motivation:
FanoutPublisherBridgeStage.postStop always completed the exposed publisher with ActorPublisher.NormalShutdownReason, even when the stage was stopped abruptly without an upstream or subscriber terminal signal. That made active and late subscribers observe a normal shutdown instead of the GraphStage abrupt termination failure.

Modification:
Track whether the bridge is stopping from an intentional terminal path. Only synthesize AbruptStageTerminationException from postStop when no terminal path was already signalled, and add a bridge-level regression test for active and late subscribers.

Result:
Controlled completion, failure, timeout, and last-subscriber cancellation keep their existing reasons, while abrupt bridge shutdown is now reported as AbruptStageTerminationException.

References:
apache#2874
@He-Pin He-Pin force-pushed the fix-fanout-publisher-abrupt-poststop branch from 69b2b6b to 32a5be3 Compare April 25, 2026 15:42
Copy link
Copy Markdown
Member

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@He-Pin He-Pin merged commit 4e2c1fe into apache:main Apr 26, 2026
9 checks passed
@He-Pin He-Pin deleted the fix-fanout-publisher-abrupt-poststop branch April 26, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants