Repository navigation
Cherry pick #108128 to 26.6: Fix LOGICAL_ERROR in on-fly mutation read when an UPDATE keep-old fallback is read under a non-constant condition - #108389
Merged
robot-ch-test-poll3 merged 5 commits intoJun 24, 2026
Conversation
…s not constant-true MutationsInterpreter lowers UPDATE col = expr WHERE cond to _CAST(if(cond, _CAST(expr, type), col), type), where type is the post-MODIFY column type. The if node is declared at that type, and its third argument is the bare on-disk pre-MODIFY column (the value kept for unmatched rows). collectColumnsConsumedByChainActions excluded that fallback edge from forced conversion unconditionally, on the premise that the kept-old value is discarded and never read. That holds only when cond is constant-true: FunctionIf then returns the then-branch and never touches the fallback. For a non-constant or constant-false cond, FunctionIf does read the fallback, but the on-disk col is left in its pre-MODIFY type while the if node expects the post-MODIFY type, so the executor aborts with LOGICAL_ERROR: Unexpected return type from if (or a FunctionIf type-equality assertion). A minimal repro: CREATE TABLE t (id UInt64, v String, b UInt8) ENGINE = MergeTree ORDER BY id; INSERT INTO t SELECT number, toString(number * 10), number % 2 FROM numbers(10); SYSTEM STOP MERGES t; ALTER TABLE t UPDATE v = 100 WHERE id > 5 SETTINGS mutations_sync = 0, alter_sync = 0; ALTER TABLE t MODIFY COLUMN v UInt64 SETTINGS mutations_sync = 0, alter_sync = 0; SELECT v, b FROM t SETTINGS apply_mutations_on_fly = 1; This crashes on-fly while the same operation materialized synchronously returns correct results. The fix ignores the keep-old fallback edge only when the if condition is a compile-time constant-true (helper ifConditionIsConstantTrue, which descends the _CAST(..., UInt8) wrapper the mutation builder adds). For a non-constant, constant-false or NULL condition the fallback counts as a genuine consume and the column is converted to the post-MODIFY type. The cross-step ordering and the query PREWHERE skip (perform_alter_conversions) are unchanged, so the already-covered cases that must stay skipped (an unconvertible on-disk value an UPDATE replaces under a constant-true condition) remain skipped. Extends 04338_on_fly_mutation_read_overwritten_lc_source with a regression case (t_keep_old_nonconst_cond): a partial UPDATE under a non-constant condition that aborts before this change and matches a synchronous UPDATE + MODIFY after it. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…tant-true-only skip The keep-old fallback edge of an UPDATE's if(cond, expr, col) is no longer ignored unconditionally. After the constant-true gate added in this PR, the fallback counts as a genuine consume except when cond is a compile-time constant-true, so the member declaration's header comment in MergeTreeReadersChain.h stated a stale invariant. This aligns the comment with the code in collectColumnsConsumedByChainActions. Comment-only, no behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The amd_tsan flaky check on ea60fcf was cancelled at the 6h GitHub Actions wall after the test harness wedged during MinIO docker setup (Restarting clickminio), before any test ran. The prior commit 63bb1e1 ran the same flaky check green in ~10 min (04338 50x OK, avg 5.6s). This empty commit re-triggers a fresh CI run.
…-if-return-type-keep-old-fallback Fix LOGICAL_ERROR in on-fly mutation read when an UPDATE keep-old fallback is read under a non-constant condition
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.
Original pull-request #108128
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job