Repository navigation
Add assertions in IColumn::mutate to verify deep unique ownership of sub-columns - #100185
Conversation
|
Workflow [PR], commit [8c8b466] Summary: ✅
AI ReviewSummaryThe PR adds ownership assertions to Missing context / blind spots
Final VerdictStatus: ✅ Approve |
8a94b4e to
1f89ce7
Compare
…exSet - ProtobufSerializer: Add `columnRef()` helper using `const_cast` for deserialization columns that are borrowed from the caller. Replace all `column->assumeMutableRef()` calls with `columnRef()`. Replace `presence_column` MutableColumnPtr with raw pointer to avoid extra ref. - MergeTreeIndexSet: Move column from block before using `assumeMutableRef` to ensure use_count == 1, then move it back afterward. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…columns Add a free function `borrowColumnRef` to centralize the `const_cast` pattern for columns that are borrowed from the caller for mutation during deserialization. Use it consistently across Nullable, LowCardinality, Array, Tuple, and OneOf serializers. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- SerializationDynamicElement.cpp: Replace `MutableColumnPtr` copy (deleted constructor) with raw `IColumn *` pointer for the `non_nullable_variant_column` alias. - Remove extra blank lines in ColumnArray.cpp and ColumnNullable.cpp. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Use `shallowMutate` instead of `IColumn::mutate` in column `create(const ColumnPtr&)` methods and temporary wrapping patterns. `IColumn::mutate` does deep recursive sub-column mutation which breaks column invariants (e.g. ColumnLowCardinality dictionary/index relationship, ColumnDynamic cached pointers). `shallowMutate` creates a shallow clone when shared (use_count > 1) or returns the same object when unique, preserving sub-column sharing which is the intended behavior for these immutable composite column creation patterns. Also make `COW::shallowMutate` public so it can be called on sub-columns from static `create` methods. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Replace `shallowMutate` with `assumeMutableForCreation` in column `create(const ColumnPtr&)` methods. `shallowMutate` clones when use_count > 1, but these methods are designed to share sub-columns (not clone them). The cloning broke column invariants, causing SIGSEGV in arrayResize with Dynamic types. `assumeMutableForCreation` is a simple type conversion (like the original `assumeMutable`) without the use_count assertion, explicitly intended for creating immutable composite objects from shared sub-objects. Also fix redundant `public:` access specifier in COW.h (clang-tidy). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…create methods The `assumeMutableForCreation` method was a backdoor that defeated the purpose of the assertion. Restore the original `assumeMutable` calls in `create(const ColumnPtr&)` methods. Any assertion failures from shared columns will point to the actual callers that need fixing — they should either pass uniquely-owned columns or clone via `shallowMutate` first. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ements The previous refactoring accidentally replaced `IColumn::mutate` (which clones shared offsets) with `assumeMutable` (which shares them) for all tuple iterations. This corrupted data: the first iteration's in-place filter modified the shared offsets, breaking subsequent iterations. Restore the original logic: clone offsets for all iterations except the last one. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Guard the diagnostic sub-column traversal in `IColumn::mutate` with `#if defined(DEBUG_OR_SANITIZER_BUILD)` so release builds do not pay the cost of walking nested subcolumns for no effect. - Restore `assumeMutableRef` calls in `chameleon_ptr` mutable accessors instead of raw `const_cast`, keeping the uniqueness check on mutable access so COW violations are still detected in debug/sanitizer builds. - Fix typo: `subolumn` → `subcolumn` in `SerializationDynamicElement.cpp`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The flaky failure of |
|
The flaky check failure is fixed in #102148, let's update the branch. |
The prior refactor inadvertently widened `COW::shallowMutate` from `protected` to `public`, exposing a shallow-only mutation primitive that bypasses deep unsharing of nested `WrappedPtr` sub-columns that `IColumn::mutate` relies on for COW safety. Since this PR strengthens COW diagnostics, the widened API surface goes in the opposite direction. Restore `shallowMutate` to `protected` and keep `mutate`/`assumeMutable`/`assumeMutableRef` `public`, matching the original structure while preserving the new `chassert(use_count == 1)` in `assumeMutable` and `assumeMutableRef`. Addresses review feedback on #100185.
…into assert-cow-ownership-in-mutate
…em per row subgroup `IColumn::mutate` on the dictionary values, which are still owned by the column chunk, cloned the whole dictionary for every row subgroup. Use the immutable `ColumnReplicated::create` overload that shares the values, as before the change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oryLimit` independent of test order The test relied on the calling thread having no `ThreadStatus`, so that every allocation goes straight to `total_memory_tracker` and hits the clamped limit. Other tests (e.g. `AllocationInterceptors.*`) call `MainThreadStatus::getInstance`, after which small allocations on the main thread are deferred as untracked memory and never reach the limit, so no exception is thrown and the test fails with `error_code == 0`. This happened in `Unit tests (amd_debug)` of the private sync PR ClickHouse/clickhouse-private#53091, where the tests run in a different order. It reproduces locally with `--gtest_shuffle`. Run the part under the memory limit in a separate `std::thread`, which has no `ThreadStatus`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 On 15bf9b8, the public CI was green. The only red check was
|
# Conflicts: # src/Storages/MergeTree/MergeTreeReaderWide.cpp
|
🕵 On 7128a74, the only failures were the six I merged |
|
🕵 On 41fb22b, the public CI was green. The only red check was |
…p-in-mutate # Conflicts: # src/QueryPipeline/RemoteQueryExecutor.cpp
|
🕵 Status on 40159aa:
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=100185&sha=40159aa954e556bc4f1b1188e2aaed3b560ad18e&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%205%2F6%29 (server killed silently during |
|
Acknowledged. I'm investigating the silent right-server death in |
|
Follow-up on the
|
|
🕵 Thanks @groeneai for tracing the I merged the latest |
|
The cause is already known, so this does not have to wait for #132409. It is return address signing (#131784, and #119685 before its revert) combined with the query profiler. Two cores of the same silent ARM death in other jobs show the chain (stress, master stateless):
The perf deaths fit: the dead binaries were built with return address signing, there were none on ARM from 2026-10-07 until the first enable, and every death I could place is at or right before Fix: #132186. A SIGILL raised inside an asynchronous stack capture on AArch64 is now recovered, whichever frame raised it, so the sample is dropped and the server keeps running. The alternative is to revert return address signing, but #131784 no longer reverts cleanly on its own after #131996, so both would have to go. |
|
🕵 Thanks @groeneai for identifying the cause of the silent ARM perf deaths: return address signing combined with the query profiler, fixed in #132186. That fix is independent of this PR. The only red job on the previous head (26bf295) was I merged the latest |
DataLakeCatalog catalog replayed from stored metadata
#132097
|
📊 Cloud Performance Report ✅ AI verdict: Release-transition baseline: compared against the most recent available 26.11 masters at or before the trusted base-commit anchor because no 26.12 master baseline exists there. no significant changes detected. K_source=4 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Investigation for #99920
This is a draft PR with diagnostic assertions to help find a COW violation bug where columns stored in
HashJoinhave theirallocatedBytes()change because internal sub-columns are modified by someone who treats immutable columns as mutable.What was found
The bug manifests as
data->allocated_size != debug_allocated_sizeexception in debug builds. Investigation narrowed it down to:Squashing.cpp:70-72fixes the bug — this optimization passes chunks through withoutIColumn::mutate, so columns remain shared with Memory engine blocksaddBlockToJoincalls — during pipeline processing of the next chunkprotect()(mprotect) doesn't catch itIColumn::mutatedeep ownership check) do NOT fire — meaning the mutation happens outside theIColumn::mutatepath entirely. Someone treats an immutable column as mutable without going throughmutate.Reproducer
The test
04049_fix_hashjoin_shared_column_allocated_sizereproduces the exception in debug builds.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/100185]
Version info
26.12.1.23-master(included in26.12and later)