Repository navigation
Fix logic error which leads endless mutation failures. - #109860
RinChanNOWWW wants to merge 1 commit into
Conversation
…re-ADD column When multiple mutations are squashed (e.g. DELETE + DROP COLUMN + DELETE), and the dropped column is later re-added with a different type and no DEFAULT expression, the mutation execution hits a logical error: Unexpected return type from ifNull. Expected Int32. Got UInt64. Bug trigger conditions: - A part physically stores column `extra` as Nullable(Int32) - Mutations are squashed: DELETE + DROP COLUMN `extra` + DELETE - After DROP, the column is re-added as `extra UInt64` (no DEFAULT) - The squashed mutation executes on the original part in one pass Execution flow that leads to the exception: 1. `AlterConversions` marks `extra` as dropped (DROP COLUMN mutation pending) 2. Reader skips reading `extra` (`isColumnDroppedByPendingMutation` = true), sets `res_columns[pos] = nullptr` 3. `fillMissingColumns` sees no DEFAULT expression (`hasDefault` = false), fills with the requested type's default (UInt64 zero) 4. `performRequiredConversions` finds `res_columns[pos]` is non-null, calls `getColumnInPart` which returns the part's old type Nullable(Int32) 5. It inserts the UInt64 column data into a Block tagged as Nullable(Int32) 6. Builds `ifNull(extra, 0)` expecting return type Int32, but actual column data is UInt64 -> type mismatch exception Root cause: `performRequiredConversions` assumes that non-null `res_columns` data matches `getColumnInPart` type (true when reader actually reads from part). But when a column is skipped by `isColumnDroppedByPendingMutation` and then filled by `fillMissingColumns` with the *requested* type, this assumption breaks. Fix: skip `performRequiredConversions` for columns marked as dropped by pending mutations - their data was not read from the part and is already in the correct requested type.
51adc48 to
5422432
Compare
|
Hello! Which bug this PR fixes? |
Hello, please see the "Error log" section in the PR summay or the test case added by this PR. There isn't any relevant issue yet. @PedroTadim |
|
Workflow [PR], commit [5422432] Summary: ❌
AI ReviewSummaryThis PR skips Findings❌ Blockers
Final Verdict
|
| { | ||
| if (res_columns[pos] == nullptr) | ||
| continue; | ||
| if (isColumnDroppedByPendingMutation(pos)) |
There was a problem hiding this comment.
This still misses rename chains. isColumnDroppedByPendingMutation ends up checking dropped_columns against columns_to_read[pos].getNameInStorage(), i.e. the old on-disk name after getColumnInPart has followed rename_map. With RENAME COLUMN a TO b; DROP COLUMN b; ADD COLUMN b UInt64, dropped_columns contains b but this path queries a, so the reader keeps the stale a data and performRequiredConversions casts it into the re-added b instead of treating b as missing/defaulted. Could we base the dropped check on the requested/logical column name, or make AlterConversions::isColumnDropped resolve old names through rename_map first, and add a regression test for that sequence?
There was a problem hiding this comment.
Deal with RENAME is quite complicated. This PR won't fix this. I'll create a new issue about it.
There was a problem hiding this comment.
Deal with RENAME is quite complicated. This PR is won't fix this. I'll create a new issue about it.
634cd0e to
5422432
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 7/7 (100.00%) · Uncovered code |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
|
Investigated the root cause. Root cause. During a squashed mutation the part is read while a
The broken assumption is that a non-null On the fix. Skipping Remaining gap (out of scope here, tracked in #109957). The rename chain Owner. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @Michicosun is the right person to fix it, and suggest a solution. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
2 similar comments
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
2 similar comments
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @Michicosun is the right person to fix it, and suggest a solution. |
1 similar comment
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @Michicosun is the right person to fix it, and suggest a solution. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @Michicosun is the right person to fix it, and suggest a solution. |
|
The robot seems to be stuck in an infinite loop. Can someone fix it? @alexey-milovidov @scanhex12 |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @Michicosun is the right person to fix it, and suggest a solution. |
1 similar comment
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @Michicosun is the right person to fix it, and suggest a solution. |
|
🎉 Crash classifier applied: Hey @groeneai, please investigate the root cause of this crash, verify whether @scanhex12 is the right person to fix it, and suggest a solution. |
|
Dear @Michicosun, 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. |
Summary
Fix type mismatch exception in performRequiredConversions after DROP+re-ADD column
When multiple mutations are squashed (e.g. DELETE + DROP COLUMN + DELETE),
and the dropped column is later re-added with a different type and no
DEFAULT expression, the mutation execution hits a logical error:
Unexpected return type from ifNull. Expected Int32. Got UInt64.
Error log
Bug trigger conditions:
extraas Nullable(Int32)extra+ DELETEextra UInt64(no DEFAULT)You can see test case
04509_drop_readd_column_different_type_mutation.sql.Execution flow that leads to the exception:
AlterConversionsmarksextraas dropped (DROP COLUMN mutation pending)extra(isColumnDroppedByPendingMutation= true),sets
res_columns[pos] = nullptrfillMissingColumnssees no DEFAULT expression (hasDefault= false),fills with the requested type's default (UInt64 zero)
performRequiredConversionsfindsres_columns[pos]is non-null,calls
getColumnInPartwhich returns the part's old type Nullable(Int32)ifNull(extra, 0)expecting return type Int32, but actual columndata is UInt64 -> type mismatch exception
Root cause
performRequiredConversionsassumes that non-nullres_columnsdata matches
getColumnInParttype (true when reader actually reads frompart). But when a column is skipped by
isColumnDroppedByPendingMutationand then filled by
fillMissingColumnswith the requested type, thisassumption breaks.
Fix
Skip
performRequiredConversionsfor columns marked as dropped bypending mutations - their data was not read from the part and is already
in the correct requested type.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix type mismatch exception in performRequiredConversions after DROP+re-ADD column