Skip to content

[VL] Honor BatchWrite.useCommitCoordinator in columnar V2 writes#12562

Draft
malinjawi wants to merge 2 commits into
apache:mainfrom
malinjawi:fix/v2-write-commit-coordinator
Draft

[VL] Honor BatchWrite.useCommitCoordinator in columnar V2 writes#12562
malinjawi wants to merge 2 commits into
apache:mainfrom
malinjawi:fix/v2-write-commit-coordinator

Conversation

@malinjawi

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

The columnar V2 write path commits every task attempt unconditionally — it ignores BatchWrite.useCommitCoordinator. With speculative execution or a retried stage, two attempts of the same partition can both call DataWriter.commit() and produce duplicate output.

This brings WritingColumnarBatchSparkTask in line with vanilla Spark's DataWritingSparkTask:

  • Thread useCommitCoordinator from the BatchWrite into the task, and gate commit() behind OutputCommitCoordinator.canCommit, throwing the standard commit-denied error when the attempt loses.
  • Skip abort() once a commit has succeeded. This path updates native write metrics after commit, and a failure there was aborting already-durable output. (Vanilla has no post-commit code that can throw, so it doesn't need this guard; we do.)
  • Count rows as Long instead of Int to avoid overflow on large partitions.

How was this patch tested?

New ColumnarDataWritingSparkTaskSuite drives the task with a recording writer factory and a stub commit coordinator: a denied attempt throws and aborts+closes the writer, a failure after commit does not abort, a failure before commit does, row counts accumulate past Int.MaxValue, and the coordinator-off path is unchanged.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (reviewed and tested before submission)

@github-actions github-actions Bot added the CORE works for Gluten Core label Jul 19, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

The columnar V2 write path committed every task attempt unconditionally,
ignoring BatchWrite.useCommitCoordinator. With speculative execution or a
retried stage, two attempts of the same partition could both call
DataWriter.commit(), producing duplicate output that vanilla Spark prevents.

This change mirrors vanilla Spark's DataWritingSparkTask semantics:

- Thread useCommitCoordinator from BatchWrite into
  WritingColumnarBatchSparkTask.run and, when enabled, gate
  DataWriter.commit() behind OutputCommitCoordinator.canCommit, throwing
  QueryExecutionErrors.commitDeniedError on denial so the denied attempt
  aborts instead of committing.
- Track whether the writer already committed and skip DataWriter.abort()
  in the failure callback after a successful commit, so a post-commit
  failure (e.g. while reporting metrics) cannot roll back durable output.
- Accumulate the per-task row count as Long to avoid Int overflow for
  partitions with more than Int.MaxValue rows.

Adds ColumnarDataWritingSparkTaskSuite covering commit-denied abort,
post-commit failure not aborting, pre-commit failure aborting, Long row
counting, and the useCommitCoordinator=false path.
@malinjawi
malinjawi force-pushed the fix/v2-write-commit-coordinator branch from c951222 to 15f4623 Compare July 19, 2026 11:17
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

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

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant