Backport/stable 25.8/92588 - #2254
Open
VighneshPath wants to merge 3 commits into
Open
Conversation
… concurrent in-place mutations ColumnNullable::shrinkToFit() now shrinks the null-map column via its own shrinkToFit() (instead of reaching into its raw data array directly), and MergeTreeReadTask::read() clones shared sub-columns via IColumn::mutate() before shrinking -- the previous use_count()==1 guard only checked the top-level column's refcount, missing the case where a column (e.g. ColumnNullable) is uniquely owned per-thread but wraps a nested column still shared with the query-wide ActionsDAG. The guard itself is kept as a cheap early-out for columns still shared at the top level; IColumn::mutate() handles the deeper, per-subcolumn sharing check that this fix actually targets. Matches upstream commit 693a065 for both src/Columns/ColumnNullable.cpp and src/Storages/MergeTree/MergeTreeReadTask.cpp exactly. The MergeTreeRangeReader.cpp hunk from the upstream PR is not included: this branch has no canInplaceFilter()/assumeMutable()->filter() fast path, so that particular crash vector doesn't exist here.
…ToFit crash Adds 03681_mergetree_shrink_const_nested_nullable, targeting the case where a constant inside PREWHERE, wrapped in materialize(toNullable(materialize(...))), produces a ColumnNullable with use_count() == 1 at the top level but a shared nested column underneath -- the case the old use_count()==1 guard in MergeTreeReadTask::read() missed. Verified: reverting the ClickHouse#92588 backport fix reproduces a SIGSEGV in jemalloc (eset_remove/extent_recycle) within seconds of running this test; with the fix in place, the test passes reliably.
Adds 03682_mergetree_shrink_const_array_float64, covering a second variant of the ClickHouse#90695/ClickHouse#92588 class of bug via ColumnArray instead of ColumnNullable: arrayMap's lambda body evaluates a bare Float64 literal over a single-element array, so ColumnConst::convertToFullColumn()'s `if (s == 1) return data;` shortcut hands out a shared literal column as the arrayMap result's nested data, wrapped in a fresh ColumnArray with top-level use_count() == 1. The old use_count()==1 guard in MergeTreeReadTask::read() missed the shared nested column here too. Verified: crashes reliably (SIGSEGV) against an unpatched 25.8 build within 30s; passes cleanly with the ClickHouse#92588 backport applied, which fixes this case too since IColumn::mutate() recurses into ColumnArray's subcolumns generically via forEachMutableSubcolumn(), not just ColumnNullable's.
VighneshPath
force-pushed
the
backport/stable-25.8/92588
branch
from
August 25, 2026 09:31
b2e5f8b to
007dd7b
Compare
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix potential crash caused by in place mutation of underlying const PREWHERE columns. This could've happened at column shrinking (
IColumn::shrinkToFit) or filtering (IColumn::filter), which could've triggered concurrently from several threads. Backport of ClickHouse#92588.Documentation entry for user-facing changes
Fix potential crash caused by in place mutation of underlying const PREWHERE columns. This could've happened at column shrinking (
IColumn::shrinkToFit) or filtering (IColumn::filter), which could've triggered concurrently from several threads. Backport of ClickHouse#92588.CI/CD Options
Exclude tests:
Regression jobs to run: