Skip to content

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

Backlog

Description

@Fokko

Apache Iceberg version: main (development)

Please describe the bug 🐞

When a catalog reports CommitFailedException for a commit that landed, Transaction.commit_transaction calls _attempt_landed(), which looks for the attempt's snapshot IDs in the refreshed table. #4520 makes it accept any one of them. Suppose another writer commits on top and then expires all of the attempt's snapshots before the check. Then none are found, and the transaction either deletes its manifests (no retries left) or commits the data again (retries left). The other writer's snapshot still lists those manifests, so scans fail with FileNotFoundError.

Reproduction with the _commit_outcomes(..., after_lost=...) helper from #4520 in tests/table/test_commit_retry.py, on a new table:

def append_on_top_and_expire() -> None:
    other = catalog.load_table(identifier)
    other.append(pa.table({"x": [9]}))
    other.maintenance.expire_snapshots().by_id(other.snapshots()[0].snapshot_id).commit()

with _commit_outcomes(catalog, "lost", after_lost=append_on_top_and_expire):
    table.append(pa.table({"x": [1]}))
  • commit.retry.num-retries=0: append() raises CommitFailedException, and the next scan fails with FileNotFoundError.
  • commit.retry.num-retries=1: append() returns, and the next scan fails with FileNotFoundError.

Possible direction

Before deleting a manifest, check whether any snapshot in the refreshed metadata still references it, and keep it if so. The review on #4520 suggests a narrower version that checks branch heads for the attempt's written manifests. Detecting the landed commit through its manifests would also stop the duplicate commit on retry. For Glue, #4533 fixes the cause in the catalog itself. A REST client can't do the same, because the server writes the metadata file and the client never learns its location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions