Skip to content

Fix: assert ref snapshot id requirements during snapshot expiration (#4200) - #4265

Open
MsMansiDhruv wants to merge 2 commits into
apache:mainfrom
MsMansiDhruv:fix/expire-snapshots-protect-refs-4200
Open

MsMansiDhruv wants to merge 2 commits into
apache:mainfrom
MsMansiDhruv:fix/expire-snapshots-protect-refs-4200

Conversation

@MsMansiDhruv

@MsMansiDhruv MsMansiDhruv commented Nov 2, 2026 •

Copy link
Copy Markdown

Closes #4200

Rationale for this change

Currently, ExpireSnapshots._commit determines protected snapshots from the table's loaded metadata and sends no table requirements (self._requirements = ()). When another transaction concurrently moves or rolls back a branch/tag (such as rolling back main to the snapshot being expired), the expiration commit succeeds and RemoveSnapshotsUpdate silently deletes that ref. In the case of main, the table completely loses its main branch and reads as empty.

This change adds AssertRefSnapshotId requirements to self._requirements for each ref protecting snapshots. If a protected ref has changed concurrently, catalog validation fails with CommitFailedException instead of removing the ref or leaving the table in an inconsistent state.

Are these changes tested?

Yes, tested via unit and integration tests in tests/table/test_expire_snapshots.py:

  • test_expire_snapshots_asserts_ref_snapshot_id_requirements: verifies that AssertRefSnapshotId is staged for all protected refs.
  • test_expire_snapshots_concurrent_rollback_fails: end-to-end integration test with SqlCatalog verifying that concurrent rollback onto an expired snapshot fails with CommitFailedException and preserves main and its rows.

Are there any user-facing changes?

No breaking API changes. Concurrent snapshot expiration safely raises CommitFailedException if a protected branch or tag changed during the operation.

Signed-off-by: Mansi Dhruv mansi.p.dhruv@gmail.com

Signed-off-by: Mansi Dhruv <mansi.p.dhruv@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.

expire_snapshots on a stale table deletes a branch moved onto the expired snapshot

1 participant