Repository navigation
[Prism] Hold elements until the side inputs of their window are ready - #41454
Draft
prodriguezdefino wants to merge 1 commit into
Draft
prodriguezdefino wants to merge 1 commit into
prodriguezdefino wants to merge 1 commit into
Conversation
Problem: A ParDo after a GroupByKey can read an empty windowed side input on Prism. An aggregation stage sets its output watermark to its earliest pending timestamp W before it fires. When it fires all its windows in one bundle, the consumer stage gets elements in windows that end after W, while its upstream watermark is still W. bundleReady only compares W with the output watermark of the side input parents, so the stage can be ready. The ordinary stage kind then takes all pending elements, but GetSideData gives the bundle only the side input windows that end at or before W. Elements in later windows read an empty side input: wrong results in Python (AsIter gives an empty iterable), a failed bundle in SDKs that reject an empty singleton. The stateful stage kind takes data elements the same way. Fix: A stage with side inputs holds a data element until the bundle watermark passes the end of the window of the element, which is the rule GetSideData uses to select side input windows. Elements in the global window and stages without side inputs are not held. The ordinary stage kind keeps held elements pending and does not reschedule for them alone, because a watermark change refreshes the stage. The stateful stage kind and hasBuildableDataLocked apply the same check to data elements. Tests: Unit tests for both stage kinds at several watermarks, and for the stage state of the race: each element in a bundle has side input data for its window. A Go integration test, ValidateWindowedSideInputsAfterGBK, reads a windowed side input after a GroupByKey.
prodriguezdefino
force-pushed
the
prism/side-input-window-ready
branch
from
December 2, 2026 09:36
02bd0a7 to
c6a689f
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem:
A
ParDoafter aGroupByKeycan read an empty windowed side input on Prism. An aggregation stage sets its output watermark to its earliest pending timestamp W before it fires. When it fires all its windows in one bundle, the consumer stage gets elements in windows that end after W, while its upstream watermark is still W.bundleReadyonly compares W with the output watermark of the side input parents, so the stage can be ready. The ordinary stage kind then takes all pending elements, butGetSideDatagives the bundle only the side input windows that end at or before W.Elements in later windows read an empty side input: wrong results in Python (
AsItergives an empty iterable), a failed bundle in SDKs that reject an empty singleton. The stateful stage kind takes data elements the same way.Fix:
A stage with side inputs holds a data element until the bundle watermark passes the end of the window of the element, which is the rule
GetSideDatauses to select side input windows. Elements in the global window and stages without side inputs are not held. The ordinary stage kind keeps held elements pending and does not reschedule for them alone, because a watermark change refreshes the stage. The stateful stage kind andhasBuildableDataLockedapply the same check to data elements.Tests:
Unit tests for both stage kinds at several watermarks, and for the stage state of the race: each element in a bundle has side input data for its window. A Go integration test,
ValidateWindowedSideInputsAfterGBK, reads a windowed side input after aGroupByKey.How to reproduce:
Expected failure:
The occurence of the failure is low:
1abc30e62a4, no fix