Skip to content

[core] Check the commit lease after the snapshot existence check - #10954

Open
LuciferYang wants to merge 3 commits into
apache:masterfrom
LuciferYang:fix/commit-lease-after-exists
Open

LuciferYang wants to merge 3 commits into
apache:masterfrom
LuciferYang:fix/commit-lease-after-exists

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

close #10953

A filesystem-managed commit checks its lease before RenamingSnapshotCommit.commitImpl, which then asks the file system whether the new snapshot file exists before it publishes. On an object store that request can outlast the lease, and the snapshot was still published. If another writer got the lock in the meantime and committed the same snapshot id, and the store's rename replaces an existing target, its snapshot was overwritten and its commit lost, although it had reported success.

commitImpl now checks the lease again after the existence check, before tryToWriteAtomic. A slow write inside tryToWriteAtomic can still outlast the lease; this only removes the extra request between the check and the write. The LATEST hint written after a successful publish is unchanged: the snapshot is already committed at that point, and a stale hint is corrected when the latest snapshot is looked up.

Tests

  • RenamingSnapshotCommitTest#testExpiredLeaseDoesNotOverwriteAnotherWritersSnapshot: two writers of one table share a lease lock on a FileIO whose rename replaces the target. Writer A's lease expires while it checks whether snapshot 2 exists, and writer B, which gets the lock then, commits snapshot 2. On master writer A overwrites it and the table loses writer B's row. With the fix writer A fails the check, retries and commits snapshot 3, and the table has all rows. With a rename that does not replace the target, master keeps all rows too.
  • RenamingSnapshotCommitTest#testCommitRechecksLeaseAfterCheckingSnapshot: the lease expires during the existence check, and the commit fails with the lease error without writing the snapshot.

It takes both a rename that replaces the target and an existence check that outlasts the lease. The JDBC and Hive locks renew on every check (8 minutes by default for JDBC), the REST lock renews in the background.

API and Format

no

Documentation

no

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.

[Bug] A filesystem commit can publish its snapshot after the lock lease expired

1 participant