Skip to content

Detect landed commits via written manifests when snapshots were expired - #4543

Open
sikadisamadeisi wants to merge 1 commit into
apache:mainfrom
sikadisamadeisi:fix/commit-retry-expired-snapshot-manifests
Open

sikadisamadeisi wants to merge 1 commit into
apache:mainfrom
sikadisamadeisi:fix/commit-retry-expired-snapshot-manifests

Conversation

@sikadisamadeisi

Copy link
Copy Markdown

Closes #4534

Rationale for this change

When a catalog reports CommitFailedException for a commit that actually landed, Transaction._attempt_landed() checks whether any snapshot ID added by the attempt is present in the refreshed table metadata. If another writer commits on top and expires all of the attempt's snapshots before _attempt_landed() runs, none of those snapshot IDs remain in metadata.snapshots, causing the transaction either to delete manifests that the newer snapshot still references (when no retries remain) or to commit the data a second time and delete the earlier manifest (when retries remain), breaking subsequent scans with FileNotFoundError.

Each commit attempt writes its new manifests under a fresh commit_uuid, so no snapshot predating the attempt can reference them, and another writer's snapshot can reference them only if the attempt landed. When snapshot ID lookup misses, _attempt_landed() now checks snapshots added since before the refresh for any manifest path in _written_manifests. If reading one of those manifest lists fails and no match is found elsewhere, CommitStateUnknownException is raised so potentially live files are not deleted.

Are these changes tested?

Yes. Added tests in tests/table/test_commit_retry.py covering:

  • A lost commit response where another writer appends on top and expires all added snapshots (commit.retry.num-retries=0), verifying the landed commit and its manifests are preserved.
  • The same interleaving with retries left (commit.retry.num-retries=1), verifying the commit is not applied twice and scans succeed.
  • An initial conflict followed by a landed retry whose snapshot is expired, verifying uncommitted manifests from the failed attempt are cleaned up while the landed attempt's manifest is kept.
  • Unreadable manifest lists on newly added snapshots raising CommitStateUnknownException without deleting written manifests.

Are there any user-facing changes?

Bug fix only; no public API changes.

If another writer commits on top of a landed commit whose response was lost and expires all of its snapshots before _attempt_landed() runs, snapshot ID lookup misses it. Check newly added snapshots in the refreshed metadata for the attempt's written manifests so cleanup keeps live manifests and retries do not commit the data a second time.

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.

Commit cleanup deletes a landed commit's manifests when another writer expires all of its snapshots

1 participant