Fix groupBy cancellation signal loss by noodlemind · Pull Request #4347 · reactor/reactor-core · GitHub
Skip to content

Fix groupBy cancellation signal loss - #4347

Open
noodlemind wants to merge 1 commit into
reactor:mainfrom
noodlemind:feature/2352-groupby-cancellation-race
Open

noodlemind wants to merge 1 commit into
reactor:mainfrom
noodlemind:feature/2352-groupby-cancellation-race

Conversation

@noodlemind

Copy link
Copy Markdown

Cancelled GroupedFlux instances no longer silently lose values that were accepted or dequeued while cancellation raced with delivery. Buffered values are handed back to GroupByMain and routed into a replacement group, preserving signal counts without scheduler isolation.

A cancellation could previously win after GroupByMain selected a group, or after the inner drain polled a value, and then clear the queue or complete downstream. This change keeps completed groups attached long enough to hand off buffered values, makes group removal identity-aware so an old group cannot remove its replacement, serializes queue mutation with cancellation, and keeps dequeue-and-delivery atomic. Outer completion waits for subscribed groups to finish any pending handoff.

Checks:

  • deterministic cancellation-after-poll regression test
  • maintainer simplified range/groupBy/take(1) reproducer
  • timed multi-threaded group cancellation reproducer
  • high-cardinality multi-scheduler stress scenario (5 consecutive runs)
  • ./gradlew :reactor-core:test spotlessCheck (10,005 tests; 9,595 passed, 410 skipped)

Fixes #2352.

Keep cancelled groups attached until buffered values can be handed to a
replacement group. Serialize dequeue delivery with cancellation so a value
cannot disappear between polling and downstream emission.

Fixes reactor#2352.

Signed-off-by: Krish <bvkcp1989@gmail.com>
@noodlemind
noodlemind marked this pull request as ready for review August 4, 2026 06:24
@noodlemind
noodlemind requested a review from a team as a code owner August 4, 2026 06:24
@noodlemind

Copy link
Copy Markdown
Author

@Sage-Pierce

Copy link
Copy Markdown
Contributor

@noodlemind it's neat to see progress on this issue! Your changes look reasonable to me, but as mainly a Reactor user and occasional contributor, I don't know that I'll be able to do much but cheer on 😅 I would much more trust reviewership from Reactor maintainers, or anyone with more expertise in how the GroupBy operator is intended to be implemented.

Just FYI (and as I understand it), projects that fall under the Spring ecosystem umbrella are a bit strained for maintenance resources these days. See this blog for more details. I also think this time of year is a popular holiday/vacation window for maintainers, so that may further lengthen turnaround time.

It may be helpful to further set expectations by keeping the Spring release calendar in mind when trying to judge when any proposed changes might be published for availability.

@skrcode

skrcode commented Aug 22, 2026

Copy link
Copy Markdown

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.

FluxGroupBy silently drops onNext signals

3 participants