Repository navigation
Conversation
Stages with a ParDo requiring time sorted input now hold each element until the input watermark passes its timestamp plus the input's allowed lateness, then process held elements in timestamp order. Previously, late but allowed elements were processed out of order. Remove testRequiresTimeSortedInputWithLateDataAndAllowedLateness from the Prism sickbay.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40886 +/- ##
===========================================
+ Coverage 0 56.40% +56.40%
===========================================
Files 0 876 +876
Lines 0 154819 +154819
===========================================
+ Hits 0 87327 +87327
- Misses 0 65633 +65633
- Partials 0 1859 +1859
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
📋 Review Summary
This PR properly implements support for @RequiresTimeSortedInput in the Prism runner by holding back elements in stateful stages until the input watermark has advanced past their timestamp plus the main input's allowed lateness (or when the watermark reaches +infinity). It also updates stage preprocessing to propagate the requirement and allowed lateness to ElementManager, adds unit tests for the new time-sorted holding behavior, and removes the newly passing Java ValidatesRunner tests from the Prism sickbay.
🔍 General Feedback
- The watermark cutoff calculation in
timeSortedCutoffcarefully prevents overflow atmtime.MaxTimestampand underflow viamtime.Subtract. hasBuildableDataLockedandbuildEventTimeBundlestay consistent with each other by sharingtimeSortedReady, ensuring empty bundles are not scheduled when all pending elements are held back for time sorting.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @jrmccluskey for label go. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Problem
A stateful DoFn annotated with
@RequiresTimeSortedInputshould get its elements in event-time order. Per thejavadoc, the runner buffers each element until the watermark passes the element's timestamp plus the allowed lateness.
Prism keeps each key's pending input in a heap ordered by event time, so every bundle is already sorted. But a stateful stage released all pending elements as soon as the watermark advanced. Late but allowed elements that arrived afterwards were processed after elements with later timestamps.
In
testRequiresTimeSortedInputWithLateDataAndAllowedLateness, Prism processed[100, ..., 1000]at watermark 100 and then[1, ..., 99], so the output started with-999instead of being all ones.Change
timestamp + allowedLateness, then processes held elements in timestamp order.Testing
TestStatefulStageKind_buildEventTimeBundle_TimeSortedInput.testRequiresTimeSortedInputWithLateDataAndAllowedLatenessfrom the Prism sickbay.Known limitation
A key's timers that sit behind held data in its queue also wait until that data is released. Java delivers timers on the watermark, independently of buffered elements. No current test depends on that.