AlgoMaster Logo
AlgoMasterCoordinate Optimistic Lakehouse Commitshard

Coordinate Optimistic Lakehouse Commits

hard

Lakehouse writers create files privately and then optimistically commit metadata. A writer using an old snapshot may still commit when intervening writes touched different partitions.

Design a LakehouseCommitCoordinator class:

  • boolean commit(int baseVersion, int[] partitions) attempts a write.
  • int currentVersion() returns the latest successful version, starting at 0.

Reject a commit when any successful version after baseVersion touched one of the requested partitions. Otherwise create the next version and record the distinct partition set. Failed attempts do not create versions. Inputs always use 0 <= baseVersion <= currentVersion().

Example 1:
Example 2:

Constraints

  • 1 <= partitions.length <= 100
  • 0 <= partitions[i] <= 10^9
  • At most 500 successful commits and 1000 total calls occur per object.
  • 0 <= baseVersion <= currentVersion().
Hints

Loading...
CallReturns
new LakehouseCommitCoordinator()null
commit(0, [1,2])true
commit(0, [3])true
commit(0, [2])false
currentVersion()2

The stale write to partition 3 is disjoint and succeeds. The stale write to partition 2 conflicts with version 1 and fails without creating version 3.

Run checks these cases. Submit also runs a larger hidden set.