Skip to content

[Spark] Retain the last watermark of a source with no update in the batch - #39823

Open
Eliaaazzz wants to merge 2 commits into
apache:masterfrom
Eliaaazzz:spark-watermark-idle-source
Open

[Spark] Retain the last watermark of a source with no update in the batch#39823
Eliaaazzz wants to merge 2 commits into
apache:masterfrom
Eliaaazzz:spark-watermark-idle-source

Conversation

@Eliaaazzz

Copy link
Copy Markdown
Contributor

GlobalWatermarkHolder.advance() rebuilt the global watermark map from only the sources that had a queued update for the completed batch and overwrote the stored map with the result. A source that reported no progress in that batch lost its last known watermark, and since SparkTimerInternals.forStreamFromSources skips ids that are missing from the map, the input watermark of every consuming stage jumped ahead of the idle source, firing timers early and dropping its later elements as late.

computeNewWatermarks now starts from the stored map and merges the per-source updates over it, so an idle source keeps its last watermark until it reports again. A source whose high watermark reached the end of time is done and holds nothing back, so it is not retained past the batch that completed it; without this, its finite synchronized processing time and low watermark would constrain consumers forever. Retained sources can disagree on the synchronized processing time, so SparkTimerInternals takes the slowest one instead of asserting equality. The stored map is also read once per advance() instead of once per updated source.

Two CreateStream test scripts (testFlattenedWithWatermarkHold, shouldTriggerProcessingTimeTimerWithSparseKey) now advance their watermarks to infinity like the other scripts. Their scripts previously stopped at a finite watermark and the tests only terminated because the dropped source no longer held the global watermark back; with retention that stalled watermark would legitimately hold it back until the test timeout.

testWatermarkRetainedForSourceWithoutUpdate fails on master with source 2 absent from the map after the second advance(); testCompletedSourceAgesOut pins the report-then-age-out behavior.

Fixes #39822.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

…atch

GlobalWatermarkHolder.advance() rebuilt the watermark map from only the
sources with a queued update and overwrote the stored map, so an idle
source lost its last watermark and consuming stages jumped ahead of it.
computeNewWatermarks now merges the updates over the stored map. A
source whose high watermark reached the end of time is done and holds
nothing back, so it is not retained. Retained sources can disagree on
the synchronized processing time, so SparkTimerInternals takes the
slowest one instead of asserting equality. Two CreateStream test
scripts now advance their watermarks to infinity like the other
scripts; with retention their stalled watermarks would otherwise hold
the global watermark back until the test timeout.
@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @damccorm added as fallback since no labels match configuration

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Spark streaming drops the stored watermark of a source with no update in a batch

1 participant