Repository navigation
Add a test for stale skip index reads with apply_mutations_on_fly and apply_patch_parts off - #106988
Conversation
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-6:20260610-141800 |
|
cc @CurtizJ @alesapin — could you review this? The query read snapshot only requested alter (READ_COLUMN) mutations when |
|
Workflow [PR], commit [64bf3bc] Summary: ✅ AI ReviewSummaryThis PR has been reduced to a focused stateless regression test for the already-merged stale skip-index type check: it exercises both the planning-time path and the direct Final Verdict
|
Pre-PR validation gate (updated for the fast-path fix, HEAD
|
| # | Question | Answer |
|---|---|---|
| a | Deterministic repro? | Yes. Built the base commit fc73f46 (pre-fix) and ran the new test against it: the server aborts every time with Logical error: 'Sizes of nested column and null map of Nullable column are not equal after deserialization (null map size = 1, nested column size = 0)' via SerializationNullable::deserializeBinaryBulkWithMultipleStreams -> MergeTreeIndexSet::deserializeBinary -> filterMarksUsingIndex. Repro is the test SQL: ALTER ... MODIFY COLUMN value Nullable(UInt64) with alter_sync=0, mutations_sync=0, then SELECT count() ... WHERE value=300 SETTINGS apply_mutations_on_fly=0, apply_patch_parts=0. |
| b | Root cause explained? | Yes. createStorageSnapshot set need_alter_mutations = apply_mutations_on_fly || apply_patch_parts. Both off => the pending READ_COLUMN alter mutation is dropped from the read snapshot => AlterConversions::getAllUpdatedColumns() is empty => canUseIndex does not exclude the type-incompatible skip index => filterMarksUsingIndex deserializes the old String-serialized SET-index granule as Nullable(UInt64) (null map size 1, nested size 0) => LOGICAL_ERROR. |
| c | Fix matches root cause? | Yes, and it now preserves the no-alter fast path per the AI Major. need_alter_mutations is requested when a pending READ_COLUMN mutation actually exists, gated on getMutationCounters().num_alter > 0 (a cheap 3-int read), instead of unconditionally true. Reads with no pending column-type change keep need_data_mutations=false && need_alter_mutations=false, so getMutationsSnapshot still hits the empty-snapshot fast path (no mutation lock, no current_mutations_by_version scan). The replicated queue initializes seen_all_data_mutations from need_data_mutations only, so an alter-only snapshot no longer walks data-mutation entries (alter/metadata mutations carry alter_version != -1 and use the metadata branch). |
| d | Test intent preserved / new tests added? | Yes. New regression test 04151_skip_index_after_alter_modify_column_nullable.sql (unchanged from prior HEAD) pins apply_mutations_on_fly=0, apply_patch_parts=0 for a String -> Nullable(UInt64) change with a pending mutation, and checks the result with both flags off, with defaults, and after materialization. |
| e | Both directions demonstrated? | Yes. Base binary (pre-fix): server aborts with the LOGICAL_ERROR above. Fixed binary (HEAD 6e4dd00): the test prints 1/1/1 matching .reference and the server stays alive. Additionally verified the fast path is preserved: a read with apply_patch_parts=0 and a pending UPDATE (data mutation, num_alter=0) returns the correct result with the server alive. Sibling tests 03702_alter_column_modify_secondary_index_general, 03702_alter_column_update_and_delete_secondary_index_general, 03702_alter_codec_index pass and match references. |
| f | Fix is general, not a narrow patch? | Yes. The fix is at snapshot construction, not a guard at the crash site, so it covers every skip-index type read with an incompatible on-disk type after any pending ALTER MODIFY COLUMN. The gating uses the existing num_alter counter (already maintained for all alter mutations), and the symmetric replicated read path is handled too. The write/merge snapshots (MergeTask uses !patch_parts.empty(), MutateTask uses true) were reviewed and are unaffected; column data reads use the part's own stored type in IMergeTreeReader, independent of the snapshot. |
Session id: cron:clickhouse-worker-slot-14:20260610-200400
|
Thanks for the review. Addressed both points in Major (preserve the no-alter fast path). For the replicated queue, Metadata. Reworded the changelog entry to "Fix a Verified locally: the new test crashes the pre-fix binary with the documented LOGICAL_ERROR and passes on the fixed binary; a read with |
|
CI finished on HEAD
Fast test, Style check, and Bugfix validation are green on this HEAD. |
CI summary, covered HEAD
|
| Check | Failure | Classification | Disposition |
|---|---|---|---|
| Stateless tests (arm_asan_ubsan, azure, sequential) | Segmentation fault (STID 0883-65ab), then Server died |
Inherited trunk corruption (multistage distributed-queries thread-teardown UAF, STID 0883-* family) |
Not PR-caused. This HEAD predates the master revert #107122 (merged 01:37 UTC 06-11), so it inherited the now-fixed corruption. The arm_asan_ubsan, azure, sequential check is clean on master across 55 commits since 03:00 UTC 06-11 (0 failures); the same pre-revert window shows this family on 16+ unrelated PRs as singletons. A rebase past 01:37 UTC 06-11 clears it. |
| Integration tests (amd_tsan, 1/6) | test_refreshable_mat_view_replicated::test_circular_dependencies_survive_restart |
Chronic flaky (38 hits / 33 distinct PRs / 3 master in 30d) | Not PR-caused (this PR only touches MergeTreeData::createStorageSnapshot). Tracked under the chronic refreshable-MV task (issue #106651). |
No PR-caused failures. The fix (skip-index over a column with a pending ALTER MODIFY COLUMN type change; regression test 04151) is unaffected.
|
Fresh independent P0 reproduction of this bug surfaced on an unrelated PR's
I verified this PR's change fixes it on current master HEAD ( CREATE TABLE t (id UInt64, value String, INDEX idx (value) TYPE set(0) GRANULARITY 1)
ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 8, min_bytes_for_wide_part = 0;
INSERT INTO t SELECT number, toString(number * 1000000000) FROM numbers(128);
SYSTEM STOP MERGES t;
ALTER TABLE t MODIFY COLUMN value Nullable(UInt64); -- alter_sync = 0, mutations_sync = 0
SELECT count() FROM t WHERE value = 300
SETTINGS force_data_skipping_indices = 'idx', use_skip_indexes_on_data_read = 1,
max_rows_to_read = 0, apply_mutations_on_fly = 0, apply_patch_parts = 0;
One note for a rebase: master's |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 11/11 (100.00%) · Uncovered code |
CI finish ledger - 035eebaCI is fully finished on this head: 174 check-runs, all completed, 1 red. Every failure below has an owner.
The two rows are one event: the coordinator abort kills the server, and Session id: cron:our-pr-ci-monitor:20260730-030000 |
Ergus
left a comment
There was a problem hiding this comment.
The regression tests is not failing over master without the fix, so the issue was already fixed or the reproduction is nor determninistic?
|
You are right. It stopped reproducing, because this PR was superseded by my own #112484.
It is not a vacuous pass on master: the mutation is still pending on 3 of 3 parts, The fix is Same for the other shape, Two consequences. With I would close this and move those two queries into |
|
Dear @Ergus, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Ergus
left a comment
There was a problem hiding this comment.
The main change in this PR is already on master. I think that we must drop changes.
Close this PR or reduce it to a test-only PR.
…ch_parts off With both settings off, the read snapshot omits a pending ALTER MODIFY COLUMN mutation, so nothing in the snapshot disables a skip index whose granules were written with the old column type. The only remaining guard is the stale-type check in IMergeTreeIndex::getDeserializedFormat (ClickHouse#112484). The existing tests for that check reach it through KILL MUTATION, metadata-only alters and absent columns; none disables both settings. The new test covers a String -> Nullable(UInt64) set index through planning-time index analysis and the direct skip index read. It asserts that the mutation is still pending on all three parts, that the stale index is consulted but prunes nothing, and, through SelectedMarks of the same direct read before (3) and after (1) the index is rebuilt, that the read-time filter runs. On 26.7, which lacks ClickHouse#112484, each of the two reads alone fails with the LOGICAL_ERROR "Sizes of nested column and null map of Nullable column are not equal after deserialization". The source change this branch used to carry (gating need_alter_mutations in createStorageSnapshot) is dropped: ClickHouse#112484 covers the same case at the deserialization boundary, plus routes that gate cannot reach. The extra ReplicatedMergeTree row in 04144 is dropped too: with alter_sync = 0 the replica applies the new column type asynchronously, so the row often read the old metadata and exercised nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
137b450 to
64bf3bc
Compare
|
Reduced to a test-only PR in 64bf3bc: the What is left is one test, I also dropped the extra |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Test-only. The source change this PR used to carry is dropped: #112484 rejects a stale skip index granule in
IMergeTreeIndex::getDeserializedFormat, which covers the same case at the deserialization boundary.With
apply_mutations_on_fly = 0andapply_patch_parts = 0the read snapshot omits a pendingALTER MODIFY COLUMNmutation, so that check is the only thing that keeps old granules from being decoded with the new type. The existing tests for it (04165and its splits) reach it throughKILL MUTATION, metadata-only alters and absent columns; none disables both settings.05317pins this route for aStringtoNullable(UInt64)set index, through planning-time index analysis and the direct skip index read, and asserts that the mutation is still pending, the stale index is consulted but prunes nothing, and the read-time filter runs.Validation:
26.7.17.7(no #112484) fails withCode: 49LOGICAL_ERROR;26.8.10.6and a master debug build pass. On master the mutation is still pending on 3 of 3 parts while the index is listed but prunes nothing, so the pass is not vacuous. It passes in 102 randomized parallel runs.Workflow [PR]
Sync PR [sync-upstream/pr/106988]
Version info
26.10.1.1491-master(included in26.10and later)