Skip to content

fix(maintenance): require full snapshot history for orphan cleanup - #2699

Draft
laskoviymishka wants to merge 1 commit into
apache:mainfrom
laskoviymishka:factory/rc-orphan-cleanup-full-history
Draft

laskoviymishka wants to merge 1 commit into
apache:mainfrom
laskoviymishka:factory/rc-orphan-cleanup-full-history

Conversation

@laskoviymishka

Copy link
Copy Markdown
Contributor

On a REST table loaded with snapshot-loading-mode=refs, Metadata().Snapshots() only holds the snapshots a branch or tag points at, so orphan cleanup planned the files of every other snapshot as orphans and deleted them. planOrphanFiles, which both PlanOrphanFiles and DeleteOrphanFiles go through, now fails before listing anything when the table has refs-only history and says to reload with snapshot-loading-mode=all. A real delete checks the refreshed table, because Refresh keeps the catalog's load mode. To let maintenance see the mode, this adds Table.SnapshotHistoryLimitedToRefs. It is part of the v0.8.0 RC blockers (item B4) and replaces #2599.

New tests cover plan, dry run and delete on a refs-only table, plus a full table whose refresh comes back refs-only; they fail without the guard, and the full-history path still removes the orphan. go build ./..., go vet ./... and go test ./table/... ./cmd/iceberg/... pass.

This is only a guard: iceberg clean-orphan-files against a refs-mode REST server now fails rather than loading full history. Reloading through FullSnapshotHistoryLoader, as #2601 does for expiration, could be a follow-up.

AI-assisted, reviewed by a human.

A REST table loaded with snapshot-loading-mode=refs only carries the
snapshots that a branch or tag points at. Orphan cleanup collected
referenced files from Metadata().Snapshots(), so the files of every
other snapshot were planned as orphans and deleted.

planOrphanFiles now fails before touching the filesystem when the table
it plans from has refs-only history, and the error says to reload with
snapshot-loading-mode=all. PlanOrphanFiles and dry runs check the table
they were given; a real DeleteOrphanFiles checks the refreshed table,
since Refresh reloads through the catalog and keeps the load mode.
ExecuteOrphanCleanup only runs plans that passed the check, and
PurgeFiles removes the whole table either way, so both are unchanged.

Table.SnapshotHistoryLimitedToRefs exposes the load mode so the
maintenance package can read it.

Signed-off-by: laskoviymishka <laskoviymishka@gmail.com>

This branch has not been deployed

No deployments
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