Repository navigation
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR ports withTimestampCursor() and withTimestampCursor(Duration) from Python (#39461) to Java's FileIO.MatchConfiguration, FileIO.Match, and FileIO.MatchAll, wiring continuous file matching into Watch.Growth.withTimestampCursor with event-time watermarking based on file modification times. The implementation and end-to-end tests are well structured, with a couple of issues to address around unused test imports and per-filepattern watermark tracking in MatchPollFn.
🔍 General Feedback
FileIOTest.javaincludes five unused imports (hasDisplayItem,not,assertNull,assertThrows,DisplayData) that will cause Checkstyle/Spotless checks to fail; it looks like a unit test forMatchConfiguration.withTimestampCursorvalidation andDisplayDatawas either omitted or removed.- In
FileIO.MatchAll.MatchPollFn,newestMtimeis stored as a single field on thePollFninstance rather than keyed by the watched filepatternelement, which can cause cross-pattern interference whenFileIO.matchAll()watches multiple filepatterns.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
9a34f2b to
8f7d086
Compare
|
Tested in Dataflow job |
|
Assigning reviewers: R: @damccorm for label java. This pull request likely touches a core component ("core" label). Please review with scrutiny. 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). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41518 +/- ##
=========================================
Coverage 57.99% 57.99%
Complexity 2831 2831
=========================================
Files 1209 1209
Lines 173011 173011
Branches 2320 2320
=========================================
Hits 100334 100334
Misses 69968 69968
Partials 2709 2709 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| Instant newest = null; | ||
| for (MatchResult.Metadata metadata : metadataList) { | ||
| Instant mtime = new Instant(ensureLastModifiedMillis(metadata)); |
There was a problem hiding this comment.
instead of throwing an exception is there some conservative behavior we can take, like assuming it was just modified? or keep the previous modified time for the file?
There was a problem hiding this comment.
timeStampCursor relies on last monotonic mtime for new modifications to work
-
if assume just modified, it degrades to matchContinuously that emit every time on poll (matchUpdated = false)
-
keep the previous modified time: unavailable due to finite allowedLateness
any mtime not reflecting the real modification time have already break the assumption and could cause data loss, and I think exception is justified here
| // takes the poll time so a quiet directory does not stall downstream event-time windows. | ||
| boolean foundNewer = newest != null && updateNewestMtime(newest); | ||
| Instant baseWatermark = | ||
| (foundNewer && newest != null && newest.isBefore(now)) ? newest : now; |
There was a problem hiding this comment.
should we additionally delay the watermark some to account for possible skew between local times and the file system times? getting it wrong could lead to data-loss if late data is not handled by the pipeline.
There was a problem hiding this comment.
Agree and in general, inconsistency of element timestamp and worker clock always exists in Beam
Regardless of this situation, now set poll watermark delta to now - max(pollInterval, allowedLateness) (previously was now - allowedLateness) which defaults to now
There was a problem hiding this comment.
Actually, this will make new element watermark too conservative such that it's delayed by pollInterval. Now use an "idleWatermarkDelta" that tracks the case when no new elements in:
-
if there are new elements,
watermark = newest - allowedLateness -
if no new element,
watermark = now - idleWatermarkDelta = now - max(pollInterval, allowedLateness)
Because poll happens with interval pollInterval, this still guarantees non-decreasing watermark while a poll has new element, then subsequent poll doesn't
|
R: @scwhittle (keeping sticky) |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
Port #39461 to Java