Skip to content

[#41297] Spark 4 streaming: fix lost output when one shuffle feeds two stateful transforms - #41307

Merged
Abacn merged 1 commit into
apache:masterfrom
tkaymak:spark4-streaming-no-exchange-reuse
Nov 13, 2026
Merged

Abacn merged 1 commit into
apache:masterfrom
tkaymak:spark4-streaming-no-exchange-reuse

Conversation

@tkaymak

@tkaymak tkaymak commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #41297, part of #36841.

In streaming, when one shuffle feeds two stateful transforms, for example a Reshuffle followed by two GroupByKeys, Spark reuses the shuffle for the second consumer. Spark 4.0.2 then gives the stateful operator above the reused shuffle no input watermark, so its timers never fire and its output is lost. This is SPARK-60862, fixed only in Spark 4.4.0, which is not released yet.

The runner now sets spark.sql.exchange.reuse to false on the session before it starts its streaming queries. It is not restored afterwards, since pipelines can share a session and a restore could reach a query that is still starting. Reuse off only costs recomputation. The TODO points at #41297 to drop it once the runner uses Spark 4.4.0 or later.

PAssertStreamingTest.testReshuffleFeedingTwoGroupByKeys runs a Reshuffle into two GroupByKeys. It fails on master (one output missing) and passes with this change.

Merge order: independent of #41256 and #41220, suggested first since it fixes silent data loss on master. All three bump the Spark 4 trigger file, I rebase the later ones.

@github-actions github-actions Bot added runners spark size/s S: 10-49 lines changed labels Nov 13, 2026
@tkaymak

tkaymak commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

R: @Abacn

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@tkaymak tkaymak changed the title [#41297] Spark 4 streaming: disable exchange reuse for streaming queries [#41297] Spark 4 streaming: fix lost output when one shuffle feeds two stateful transforms Nov 13, 2026
@Abacn
Abacn merged commit 3514ee8 into apache:master Nov 13, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

runners size/s S: 10-49 lines changed spark

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Spark 4 streaming runner drops output when one shuffle feeds two stateful transforms

2 participants