Repository navigation
[Spark] Retain the last watermark of a source with no update in the batch #39823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
damccorm
merged 5 commits into
apache:master
from
Eliaaazzz:spark-watermark-idle-source
Sep 15, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40d816d
[Spark] Retain the last watermark of a source with no update in the b…
Eliaaazzz 6019cb2
Merge remote-tracking branch 'upstream/master' into spark-watermark-i…
Eliaaazzz 2dd84f7
[Spark] Trigger the Spark ValidatesRunner and portable streaming post…
Eliaaazzz c51792b
Merge remote-tracking branch 'upstream/master' into spark-watermark-i…
Eliaaazzz 52f3715
[Spark] State why a completed source is dropped from the watermarks
Eliaaazzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/trigger_files/beam_PostCommit_Java_PVR_Spark3_Streaming.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run", | ||
| "modification": 8, | ||
| "modification": 9, | ||
| "https://github.com/apache/beam/pull/39990": "removing dead code from FnApiDoFnRunner" | ||
| } |
2 changes: 1 addition & 1 deletion
2
.github/trigger_files/beam_PostCommit_Java_ValidatesRunner_Spark.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "comment": "Modify this file in a trivial way to cause this test suite to run", | ||
| "modification": 3 | ||
| "modification": 4 | ||
| } |
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this used/why do we only return if there are updates? Does it actually save us anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasUpdatesrestores a signal the pre-change code got for free.The caller is
advance(batchId), which skips both publication calls when the returned map is empty:Before this change
newValuesstarted empty and only a source with a queued update got an entry, so a batch where every queue was empty produced an empty map andadvancepublished nothing. SeedingnewValuesfrom the stored map means a quiet batch now yields a non-empty map whenever a stored source still hashigh < TIMESTAMP_MAX_VALUE.hasUpdatesis what keeps that batch from publishing.What it saves on such a batch is the
removeBlockplusputSinglepair and the local copy assignment. The comments onwriteRemoteWatermarkBlock, and #18426 which they link, describe the window where an executor fetchingWATERMARKS_BLOCK_IDfinds nothing. The saving is narrow: the block fetch, the seeding and the queue scan all still happen.One consequence is worth stating plainly. On a batch where every queue is empty, the stored block keeps a source whose high watermark already reached
TIMESTAMP_MAX_VALUE, which seeding would have pruned. Such a source can still hold the effective low watermark back, becauseSparkTimerInternals.forStreamFromSourcestakes the slowest low watermark and a completed high watermark does not imply a completed low watermark.testCompletedSourceAgesOutuses exactly that shape, low at+5mswith high atTIMESTAMP_MAX_VALUE. The pre-change code also published nothing on an all-quiet batch, so that persistence predates this PR. What the guard defers is the pruning seeding introduced. A completed source drops out on the next published batch where its own queue is empty and another source supplies an update, and the update loop puts it back on any batch where it does report.Dropping the flag is not the same as publishing every batch. On a quiet batch it would publish the seeded map, which prunes completed sources as long as one unfinished source remains. Once every stored source has completed, seeding yields an empty map and
advancepublishes nothing regardless, so clearing that block would needadvanceto tell "nothing to publish" apart from "publish this empty map".The tests cover retention and pruning on a batch where another source updates. They do not cover the all-queues-empty path. I can add that case if you want the behavior pinned down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this helps