Skip to content

Cancel write buffers in IcebergStorageSink on exception#96998

Merged
alexey-milovidov merged 1 commit intomasterfrom
fix-iceberg-sink-write-buffer-not-canceled
Feb 15, 2026
Merged

Cancel write buffers in IcebergStorageSink on exception#96998
alexey-milovidov merged 1 commit intomasterfrom
fix-iceberg-sink-write-buffer-not-canceled

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov commented Feb 15, 2026

Summary

  • Override onException in IcebergStorageSink to call cancelBuffers, ensuring write buffers are properly canceled when an error occurs during INSERT into an Iceberg table
  • Add null checks in MultipleFileWriter::cancel since buffers may not exist if no data was consumed or may already have been released after successful onFinish
  • Fixes assertion "WriteBuffer is neither finalized nor canceled in destructor" found by AST fuzzer in stress tests

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96613&sha=89c8476a82ec00b6007e1def0608e4d049445a79&name_0=PR&name_1=Stress%20test%20%28arm_asan%29
#96613

Test plan

  • Verified the fix compiles without errors or warnings
  • CI stress tests should pass without the WriteBuffer assertion failure

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

When an error occurs during INSERT INTO an Iceberg table (e.g., from the
AST fuzzer), `onFinish` is never called, so write buffers inside
`MultipleFileWriter` are never finalized or canceled. When the sink is
destroyed, `WriteBuffer::~WriteBuffer` triggers a "WriteBuffer is
neither finalized nor canceled in destructor" assertion.

Override `onException` in `IcebergStorageSink` to call `cancelBuffers`,
ensuring all write buffers are properly canceled on error. Also add null
checks in `MultipleFileWriter::cancel` since buffers may not exist if no
data was consumed, or may already have been released after a successful
`onFinish`.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96613&sha=89c8476a82ec00b6007e1def0608e4d049445a79&name_0=PR&name_1=Stress%20test%20%28arm_asan%29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented Feb 15, 2026

Workflow [PR], commit [8c6b973]

Summary:

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Feb 15, 2026
@alexey-milovidov alexey-milovidov self-assigned this Feb 15, 2026
@alexey-milovidov
Copy link
Copy Markdown
Member Author

Looks okay.

@alexey-milovidov alexey-milovidov merged commit 7e36c53 into master Feb 15, 2026
133 of 134 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-iceberg-sink-write-buffer-not-canceled branch February 15, 2026 19:17
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants