Repository navigation
Fix SIGSEGV in MergeTreeDataPartWriterWide::cancel during merge cancellation - #101936
Merged
Merged
Conversation
…cellation The Wide writer's `addStreams` used `operator[]=make_unique<>()` which modifies the map before evaluating `make_unique`. If the constructor throws (e.g. `MEMORY_LIMIT_EXCEEDED`), a null entry remains in `column_streams`. When `cancel()` iterates the map and dereferences the null entry, it crashes with SIGSEGV. Replace with `emplace` so `make_unique` is evaluated before the map is modified — if it throws, no null entry is left. Also add a defensive null check in `cancel()`. Same class of bug as #101292 (Compact writer fix). ClickHouse/clickhouse-private#1518 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [f2302d1] Summary: ✅ AI ReviewSummaryThis PR fixes an exception-path bug in ClickHouse Rules
Final Verdict
|
Algunenano
approved these changes
Apr 7, 2026
Add a regression test using a failpoint to verify that `MergeTreeDataPartWriterWide::cancel` does not SIGSEGV when `addStreams` throws mid-way. Also replace `operator[]` with `.at()` in `flushMarkToFile` and `getCurrentMarksForColumn` to fail fast on missing streams instead of silently inserting null entries. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The failpoint `wide_part_writer_fail_in_add_streams` was `ONCE`, so a background merge could consume it before the explicit `OPTIMIZE` ran. Change it to `REGULAR`, stop merges before inserts, and restart them only after the failpoint is armed. Also add `no-random-merge-tree-settings` to avoid unexpected settings interfering with the test. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
LLVM Coverage Report
Changed lines: 100.00% (35/35) · Uncovered code |
This was referenced Apr 9, 2026
robot-clickhouse
added a commit
that referenced
this pull request
Apr 9, 2026
…:cancel during merge cancellation
robot-clickhouse
added a commit
that referenced
this pull request
Apr 9, 2026
…:cancel during merge cancellation
clickhouse-gh Bot
added a commit
that referenced
this pull request
Apr 9, 2026
Backport #101936 to 26.2: Fix SIGSEGV in MergeTreeDataPartWriterWide::cancel during merge cancellation
antonio2368
added a commit
that referenced
this pull request
Apr 10, 2026
Backport #101936 to 26.3: Fix SIGSEGV in MergeTreeDataPartWriterWide::cancel during merge cancellation
robot-clickhouse
added a commit
that referenced
this pull request
Apr 10, 2026
…:cancel during merge cancellation
robot-clickhouse
added a commit
that referenced
this pull request
Apr 10, 2026
…:cancel during merge cancellation
Algunenano
added a commit
that referenced
this pull request
May 4, 2026
Backport #101936 to 25.8: Fix SIGSEGV in MergeTreeDataPartWriterWide::cancel during merge cancellation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix SIGSEGV in
MergeTreeDataPartWriterWide::cancelduring merge cancellation.The Wide writer's
addStreamsusedoperator[]=make_unique<>()which modifies the map before evaluatingmake_unique. If the constructor throws (e.g.MEMORY_LIMIT_EXCEEDED), a null entry remains incolumn_streams. Whencancel()iterates the map and dereferences the null entry, it crashes with SIGSEGV.Replace with
emplacesomake_uniqueis evaluated before the map is modified — if it throws, no null entry is left. Also add a defensive null check incancel().Same class of bug as #101292 (Compact writer fix).
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix SIGSEGV in
MergeTreeDataPartWriterWide::cancelwhen a stream constructor throws duringaddStreams, leaving a null entry incolumn_streams.Documentation entry for user-facing changes
Version info
26.4.1.72626.3.6.8,26.2.10.8,25.8.23.13