Repository navigation
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260713-021200 |
|
cc @Avogar @CurtizJ — could you review this? It extends the #107561 fix: |
|
Workflow [PR], commit [b225985] Summary: ✅
AI ReviewSummaryThis PR fixes the partial-mutation checksum reconciliation bug that dropped a freshly rewritten Final VerdictStatus: ✅ Approve |
CI finish ledger — 0ddcf4eEvery failure below has an owner: a fixing PR (ours), or a full-effort fix task whose fixing-PR link will be posted here when it opens. No PR-caused failures on this PR (the diff only fixes the MODIFY COLUMN -> Dynamic
Session id: cron:our-pr-ci-monitor:20260713-073000 |
|
Update on the Full-effort investigation complete, no fixing PR warranted:
Disposition: benign stress-harness self-throttle inside a passing job. No engine bug and no non-speculative CI change to make. Will reopen if this signature ever appears on plain master (that recurrence would be a new signal). |
CI finish ledger — 0ddcf4eEvery failure below has an owner: a fixing PR (external), or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260716-060000 |
|
Re: the re-posted
Disposition unchanged: benign stress-harness self-throttle inside a passing job. Will reopen only if it appears on plain master. |
Avogar
left a comment
There was a problem hiding this comment.
I don't like this fix. It makes the alter modify column to Dynamic/JSON ineffective because of whole part rewrite. The logic in removing files is broken - we just should not remove files from checksums if this file was written by the writer with new type. We have a defect in stale files accounting and we need to fix that.
So, the fix should be - before removing file from checksums, check if this file was rewritten by the writer
0ddcf4e to
0024c31
Compare
|
Thanks, reworked to keep the partial-mutation path and fix the stale-files accounting instead. Root cause: on the partial path the writer does re-create the new column's data-dependent streams ( Fix: before removing a file from checksums in the Verified deterministically: reproducer aborts without the fix ( Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260717-093600 |
CI finish ledger — 0024c31CI fully finished (Finish Workflow pass; 0 checks queued/in-progress). One test failure, non-PR-caused, with an owner. (Mergeable Check reflects the prior CHANGES_REQUESTED review state, now addressed by the reworked push, not a CI job failure.)
Session id: cron:our-pr-ci-monitor:20260717-170000 |
…to Dynamic ALTER MODIFY COLUMN that changes a column into a type with dynamic subcolumns (e.g. Variant -> Dynamic, String -> JSON) on a Wide part is handled by the partial-mutation path. The writer re-creates the new column's data-dependent streams (variant_discr, SharedVariant, element streams), but stale-file accounting in collectFilesForRenames flags the old source stream for removal by comparing state-less stream enumerations, which do not see those new substreams. finalize() then erased the freshly written stream from checksums.txt, leaving the file on disk but absent from checksums, so any later read or merge aborted with "Stream <col>.variant_discr ... is not found". Keep the partial-mutation path (do not force a full part rewrite) and fix the stale-file accounting instead: before removing a file from checksums, skip any file the writer just produced for the mutated columns. Extends the fix for ClickHouse#107561 to the case where the source column is not itself dynamic. Adds regression test 04370 covering Variant -> Dynamic and String -> JSON, with a DETACH/ATTACH reload to validate checksums.txt. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Without min_bytes_for_full_part_storage pinned, CI randomization can make these tiny parts Packed, which takes the full-rewrite path and never reaches the stale-file accounting the test covers: the test then passed on unfixed code. The String -> JSON case had no colliding stream name, so it did not exercise the guard either. Replaced it with a column declared Variant and then modified into Dynamic, which is the shape the AST fuzzer produced in Stress test (arm_tsan).
A full rewrite would satisfy every other assertion while bypassing the stale-file accounting, so assert MutationSomePartColumns via system.part_log. Also record why the JSON cases were dropped: String -> JSON has no colliding stream name and passes with or without the fix, and Variant -> JSON is rejected because only String/Map/Object/Tuple/JSON can be cast to JSON.
0024c31 to
ca6e104
Compare
|
Rebased onto current master ( Two test defects found while verifying, both measured on a pristine master build rather than argued:
Also added an assertion that the MODIFY really takes the partial-mutation path, via Verification, all on build id
|
CI finish ledger - ca6e104Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
PR-caused gate: ZERO. My diff adds the missing Session id: cron:our-pr-ci-monitor:20260727-073000 |
SYSTEM FLUSH LOGS part_log is not a synchronization point for a successful mutation: mutations_sync = 2 can return before the MutatePart row is visible, so the partial-path assertion could intermittently read zero rows and fail even when the fix under test is correct. Reuse the retry-until-the-row-appears pattern already used by 03221_mutate_profile_events.sh and 03221_mutation_analyzer_skip_part.sh. Coverage is unchanged: Variant -> Dynamic and the Variant-declared-up-front shape, each with CHECK TABLE and a DETACH/ATTACH reload, plus the partial-vs-full path assertion. The test needs no tags and stays parallel-safe. Co-Authored-By: Claude Fable 5 <[email protected]>
Companion to the previous commit, which removed the .sql form. Co-Authored-By: Claude Fable 5 <[email protected]>
Both inserts targeted the same unpartitioned table, so a background merge could combine them before the ALTER and leave a single MutatePart entry. The retry loop would then spin out its full budget before falling through, and the assertion still passed, so the wait was not deterministic. Partition the table like 03221_mutate_profile_events.sh does and wait for the exact entry count. Co-Authored-By: Claude Fable 5 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 16/18 (88.89%) · Uncovered code |
CI finish ledger - b225985CI is fully finished on this head and there are no failures to own. Finish Workflow and Config
This head is the Session id: cron:our-pr-ci-monitor:20260731-023000 |
|
Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment. TL;DRFix missing variant_discr stream when MODIFY COLUMN turns a column into Dynamic ClickGap verified: reproduced it with the script below on Reproduction-- Wide-part table; MODIFY a column into Dynamic (partial-mutation path), then read/merge.
-- On a buggy build this aborts with:
-- Code: 49. Stream y.variant_discr for column y with type Dynamic(max_types=18) is not found (LOGICAL_ERROR)
SET allow_experimental_variant_type = 1;
SET allow_experimental_dynamic_type = 1;
SET use_variant_as_common_type = 1;
CREATE TABLE t_modify_to_dyn (x UInt64, y UInt64)
ENGINE = MergeTree ORDER BY x
SETTINGS min_rows_for_wide_part = 1, min_bytes_for_wide_part = 1,
min_bytes_for_full_part_storage = 0, min_rows_for_full_part_storage = 0;
INSERT INTO t_modify_to_dyn SELECT number, number FROM numbers(3);
ALTER TABLE t_modify_to_dyn MODIFY COLUMN y Variant(UInt64, String) SETTINGS mutations_sync = 2;
INSERT INTO t_modify_to_dyn SELECT number, multiIf(number % 2 = 0, number, 'str_' || toString(number)) FROM numbers(3, 3);
ALTER TABLE t_modify_to_dyn MODIFY COLUMN y Dynamic(max_types = 18) SETTINGS mutations_sync = 2;
INSERT INTO t_modify_to_dyn SELECT number, number FROM numbers(6, 3);
OPTIMIZE TABLE t_modify_to_dyn FINAL;
SELECT x, y FROM t_modify_to_dyn ORDER BY x;Bisect
Affects
Suggested next stepThe bug reproduces as far back as the oldest tested release ( Component: cc fix PR author: @groeneai ClickGap · Finding: Triage metadata
|
Related: #107561
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a logical error
Stream <col>.variant_discr ... is not found(server abort in debug and sanitizer builds) whenALTER TABLE ... MODIFY COLUMNchanges a column into a type with dynamic subcolumns (for exampleVariantintoDynamic) on a table with Wide parts, and the part is later read or merged.Description
Extends the fix for #107561 to the case where the source column is not itself a dynamic-structure column.
Such a
MODIFY COLUMNis handled by the partial-mutation path, and there the writer does correctly re-create the new column's data-dependent streams (variant_discr,SharedVariant, the element streams) intochanged_checksums. The defect is in stale-file accounting:collectFilesForRenamesdecides what to drop by comparing state-lessgetStreamCountsenumerations, which cannot see those substreams, so it flags the freshly written stream for removal.MutateSomePartColumns::finalizethen erases it fromchecksums.txt, leaving the file on disk but absent from the checksums.IMergeTreeDataPart::getStreamNameForColumnresolves streams against the checksums, sovariant_discrcannot be found and every later read or merge aborts inMergeTreeReaderWide::getStream.The fix records the files the writer just produced and skips exactly those in the stale-file removal loop, so a stream that was rewritten for the new column type survives. The mutation stays on the partial path and is not turned into a whole-part rewrite.
Reproducer, added as
04370_modify_column_to_dynamic_mutation_streams.sh: it aborts on master withStream y.variant_discr for column y with type Dynamic(max_types=18) is not foundand passes with this PR. It coversVarianttoDynamicboth from a non-dynamic source type and from a column declaredVariantup front, each withCHECK TABLEand aDETACH/ATTACHreload, plus an assertion that the mutation really did take the partial path.Version info
26.8.1.500(included in26.8and later)