HeartSaVioR opened a new pull request, #60700: URL: https://github.com/apache/spark/pull/60700
### What changes were proposed in this pull request? With state format version 4, a stream-stream join starts each batch's eviction scan after the previous batch's cutoff. This PR makes the first batch of each run scan from the start, as it already did for batch 0. That covers a restart from a checkpoint whose previous run evicted less state than the restarted query's cutoffs imply. State formats 2 and 3 evaluate every stored row each batch, so they are not affected. ### Why are the changes needed? An upgrade can raise a cutoff. For example, SPARK-61985 (#60664) removes a constant-only cap from the range cutoff, so state from an older version has rows below the new cutoff. V4 never scans them again. Example, a left outer join with 1 second watermarks: ```sql leftKey = rightKey AND lt > rt - INTERVAL 5 SECONDS AND CAST(lt AS LONG) > 10 ``` | Step | Input | Output | |---|---|---| | Run without SPARK-61985 | left (1, 20 s), right (9, 20 s); left (8, 40 s), right (9, 40 s); right (9, 41 s) | none (the cutoff is capped at 10 s) | | Restart with SPARK-61985 | left (8, 60 s), right (9, 60 s) | V2 and V3: `(1, 20, null)`. V4: none, and the row stays in state | With this PR, V4 also emits `(1, 20, null)`. Master shows the same skip without an upgrade, when a restart tightens a range bound, for example from `lt > rt - INTERVAL 10 SECONDS` to `lt > rt - INTERVAL 5 SECONDS`. ### Does this PR introduce _any_ user-facing change? Yes. With V4, the first batch after a restart evicts the rows that the previous run's cutoff left, and outer joins emit them, as V2 and V3 do. That batch scans the V4 timestamp index up to the cutoff once. ### How was this patch tested? New test in `StreamingOuterJoinBase`, run with state format V2, V3 and V4: a left outer join restarts with a cutoff above the previous run's. V4 fails without this PR. The outer join V2 and V3 suites and the V4 suites pass. The SPARK-61985 example above was also run across builds (first run on a build without SPARK-61985, restart on a build with it and this change). ### Note for reviewers, including AI review Please review only this PR's own commit. For each finding, give a runnable reproducer and say whether master has the same behavior. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 This pull request and its description were written by Isaac. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
