Skip to content

[core] Read full end state for diff starting before all retained snapshots - #10210

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-020-diff-early-timestamp
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-020-diff-early-timestamp

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant