[core] Read full end state for diff starting before all retained snapshots - #10210
Open
LuciferYang wants to merge 1 commit into
Open
LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
When the start timestamp of an incremental-between-timestamp diff query predates every retained snapshot, the true "before" state is empty or has been expired, so every row live at the end belongs in the diff. The code already returned a full static read at the end snapshot when the earliest retained snapshot was the first snapshot, but after snapshot expiry removed it, the diff started from the earliest retained snapshot instead — silently dropping rows created at or before that snapshot that were still live, which the un-expired case reports. Return the static full read whenever no snapshot is at or before the start timestamp, regardless of which snapshot is the earliest retained one. Assisted-by: GLM-5.3
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.
Purpose
When an incremental-between-timestamp diff query has a start timestamp that predates every retained snapshot, the true "before" state is empty or has been expired, so every row live at the end snapshot belongs in the diff.
The code already returned a full static read at the end snapshot when the earliest retained snapshot was the first snapshot, but after snapshot expiry removed the first snapshot it instead diffed from the earliest retained snapshot, silently dropping rows created at or before that snapshot that were still live.
This returns the static full end read whenever no snapshot is at or before the start timestamp, independent of which snapshot is currently the earliest retained one.
Note: when the start timestamp lands inside the already-expired region (the earliest retained snapshot was committed after the start), the exact diff is unrecoverable. This returns the full end state, which may re-include rows that already existed at the start, a visible and dedupable over-return, rather than silently dropping still-live rows. A diff whose start precedes the retention window should be treated as best-effort.
Tests
Adds
IncrementalTimeStampTableTest.testDiffFromBeforeEarliestRetainedSnapshot, which writes three snapshots, expires the first so the earliest retained snapshot is no longer snapshot 1, runs a diff from a start timestamp before all snapshots, and asserts all three live rows are returned. This case fails on the current code and passes with the fix.API and Format
No.
Documentation
No.