Skip to content

[core] Handle missing snapshots in branch time travel - #10860

Open
LsomeYeah wants to merge 4 commits into
apache:masterfrom
LsomeYeah:codex/fix-fallback-empty-time-travel
Open

LsomeYeah wants to merge 4 commits into
apache:masterfrom
LsomeYeah:codex/fix-fallback-empty-time-travel

Conversation

@LsomeYeah

@LsomeYeah LsomeYeah commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fix snapshot-ID time travel when reading with a fallback or primary branch whose snapshots do not cover the requested time.

The existing rewriteOtherOptions() converts the current branch's snapshot ID to a commit time and finds a snapshot in the other branch at or before that time. When none exists, it substitutes snapshot 1 without checking availability. This makes an empty branch fail with There is currently no snapshot., can read future data when snapshot 1 exists, and fails when snapshot 1 has expired even if other snapshots remain.

Changes

  • Keep snapshot selection in rewriteOtherOptions(). If no time-aligned snapshot exists, look up the earliest currently available snapshot instead of hard-coding snapshot 1.
  • Add the boolean option scan.fallback-branch.allow-earliest-snapshot (default false), applying to both fallback and primary branches in this snapshot-ID alignment path, including numeric scan.version.
  • For a nonempty other branch with no time match, fail by default. When the option is enabled, warn and select its earliest available snapshot, which may be newer than the requested time.
  • For an empty other branch with a fixed snapshot-ID scan, warn and use a private empty scan for data planning and partition listing. The current branch is still scanned normally.
  • Resolve the actual snapshot before the existing table-copy path loads its historical schema. No separate scan-time snapshot resolver or additional copyWithoutTimeTravel() call is introduced.

Compatibility

The default rejection of a nonempty branch with no time match is intentional: previously, whether future data could be read depended on whether snapshot 1 still existed. Enabling the new option explicitly permits reading the earliest available snapshot, including after snapshot 1 has expired. Empty branches are skipped regardless of the option value.

This change is scoped to the existing snapshot-ID branch-alignment path. It does not add timestamp, tag, watermark, or chain-table time-travel support. Ordinary tables still reject explicitly requested missing or expired snapshots; existing tag-backed reads are preserved. No public scan API or split-routing logic is changed.

Tests

Four focused new test methods, with 11 test/parameterized invocations, cover:

  • Empty fallback/primary branches with snapshot-ID and numeric-version selectors, either option value, a latest-read control, and partition listing.
  • No time-aligned snapshot with snapshot 1 present or expired, under both branch priorities: default rejection, opt-in earliest selection rather than latest, historical schema restoration after schema evolution, and option inheritance/overrides.
  • Ordinary empty/expired snapshot requests remaining errors even when the option is enabled.
  • Tag-backed reads succeeding when the other branch has no active snapshots.

Local validation against a817f4c75a, using Java 8:

  • FallbackReadFileStoreTableTest: 37 passed.
  • ChainTableFileStoreTableTest: 57 passed (existing regression tests).
  • Total: 94 passed, 0 failures, 0 errors, 0 skipped.
  • Core spotless:check, checkstyle:check, and git diff --check passed.

No external-engine or production integration tests were run.

@LsomeYeah LsomeYeah changed the title [WIP][core] Handle missing snapshots in branch time travel [core] Handle missing snapshots in branch time travel Oct 30, 2026
@LsomeYeah
LsomeYeah marked this pull request as ready for review October 30, 2026 02:15
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