smaheshwar-pltr opened a new pull request, #16825:
URL: https://github.com/apache/iceberg/pull/16825

   ## Core: Serialize commits in `BaseCommitService`
   
   Relates to #9521.
   
   ### Problem
   
   With `partial-progress.enabled=true` and a high 
`max-concurrent-file-group-rewrites`, rewrites hit many `CommitFailedException` 
retries on the table. Setting concurrency to `1`, or disabling partial 
progress, avoids it.
   
   ### Cause
   
   The single-threaded `committerService` exists to serialize table commits, 
but commits weren't running on it during rewrites. `offer()` called 
`commitReadyCommitGroups()` directly, so `commitOrClean()` executed on the 
calling rewrite thread — and the `synchronized` block guarded only batch 
*selection*, not the commit itself. Many concurrent rewrites therefore 
committed to the table in parallel and conflicted. (During the active phase the 
committer thread only committed once `running` was false, so it sat idle.)
   
   This is the same single-committer invariant the Flink sink already enforces, 
where `FlinkSink` pins `IcebergFilesCommitter` to 
`.setParallelism(1).setMaxParallelism(1)` — concurrency belongs in the writers, 
not the committer.
   
   Beyond retries, the conflicts make `succeededCommits()` fall short, 
inflating the `failedCommits` count in `RewriteDataFilesSparkAction`, which can 
exceed `partial-progress.max-failed-commits` and fail the whole rewrite.
   
   ### Fix
   
   Commit only on the single committer thread: `offer()` just enqueues, and the 
committer loop commits ready batches throughout (not just at drain). Commits to 
the table are now serialized. Batching, partial-progress behavior, internal 
bookkeeping, and `close()` drain/abort/timeout are unchanged. The public API 
and the `commitOrClean` / `abortFileGroup` contract are untouched.
   
   ### Testing
   
   Adds `testCommitsAreSerialized`, which asserts `commitOrClean` is never 
invoked by more than one thread at once. It fails on the pre-fix code (observes 
up to N concurrent commits) and passes after. Existing `TestCommitService` 
cases pass unchanged.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to