Repository navigation
Conversation
SnapshotManager reads a snapshot by id only from the snapshot-N file, even when the table comes from a catalog that manages snapshot versions and the same SnapshotManager already loads the latest snapshot through the catalog. The file is a best-effort mirror: a rollback deletes snapshot files under ids that later commits can reuse, and a commit's mirror write can still be in flight, so a by-id read can fail with FileNotFoundException while the catalog still holds the snapshot. Readers that resolve the latest id from the catalog and then re-read that id from the file system degrade an authoritative answer into a mirror read. Add SnapshotLoader.load(version), implemented through the existing REST loadSnapshot(identifier, version) contract, and consult it in snapshot(long) and tryGetSnapshot(long): catalog first, file system as fallback, and the catalog again after a file system miss before failing. A catalog answer with a mismatched snapshot id is rejected. Writes keep file system truth: latestSnapshotFromFileSystem, earliestSnapshot and snapshotsWithId still read only the file system.
Use the numeric snapshot ID in the loader and share lookup, validation, and cache handling between the two by-ID read methods. Recheck the catalog when the file is missing and preserve each method's retry and exception behavior. A REST server can decline the version endpoint with HTTP 501, while permission errors must reach the caller. Writer recovery, expiration, and snapshot listings need the file on disk. Bypass the shared cache for those reads on catalog-managed tables, since it can contain a different snapshot at the same path. Keep the loader's serialization UID compatible with the existing implementation.
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
A catalog can publish a snapshot before its file becomes visible. A reader can obtain the latest ID from the catalog and then fail to read that same snapshot by ID. This follows up on the file retry added in #11276.
On a cache miss,
snapshot(id)andtryGetSnapshot(id)now ask a version-managing catalog for that ID. Both fall back to the file when the catalog cannot supply a matching snapshot and check the catalog once more if the file is missing. Each keeps its existing file retry and exception behavior. REST permission errors propagate to the caller.Writer recovery, expiration, and snapshot listings read snapshot contents from disk. This matters when the shared cache holds a catalog snapshot under the same ID as a different file.
Tests