Repository navigation
Test alternative for #114561 - #115638
Test alternative for #114561#115638Avogar wants to merge 4 commits into
Conversation
…ation is pending Applied from #114561 by Shaohua Wang (tiandiwonder) as the base for follow-up work. Reading a MATERIALIZED column that reaches an updated column only through another MATERIALIZED column returned the stale on-disk value, while reading the whole chain returned the recomputed one, so the result depended on the select list. Selecting a MATERIALIZED column together with an updated one could also fail with `UNKNOWN_IDENTIFIER`. `AlterConversions::addColumnsRequiredForMaterialized` now closes the read set over the MATERIALIZED columns it contains instead of looking one hop deep, normalises defaults over subcolumns with `replaceSubcolumnsToGetSubcolumnFunctionInQuery`, and skips columns whose expression reads an `EPHEMERAL` one. `MutationsInterpreter::prepare` resolves `MATERIALIZED` defaults against every column of the table rather than only the ones the read task reads. Co-Authored-By: Shaohua Wang <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ncy graph Two independent problems in the same plumbing. The read set of an on-fly read was closed over MATERIALIZED chains once, before `filterMutationCommands` ran. But that function is itself what puts the columns the surviving commands read into the set, so anything it added was never closed over: a `DELETE WHERE m2 > 100` or an `UPDATE y = m2` kept a command alive while the chain behind `m2` stayed out of the read set, and the pending `UPDATE` of its base column was dropped as irrelevant. The result depended on the select list, exactly as before the chain fix. The closure and the filter now iterate until the read set stops growing. `filterMutationCommands` also pushed identifiers into the read set as written, so a command naming a subcolumn in dot syntax put `t.a` there while the set is keyed on storage columns. That reached `MutationsInterpreter` as an available column and made every read of the table fail with `NO_SUCH_COLUMN_IN_TABLE` while the mutation was pending, with no MATERIALIZED column involved at all. Identifiers are now mapped through `getNameInStorage`. The analysis of MATERIALIZED defaults was open-coded at four sites with different source column lists, and the read path and the interpreter have to agree on it or a dependency they spell differently leaves the mutation unapplied. It moves into `MaterializedColumnDependencies`, which owns the subcolumn rewrite, the `TreeRewriter` analysis and the `EPHEMERAL` policy, and answers the reachability question both sides ask. The five lambdas and two memo maps in `addColumnsRequiredForMaterialized` collapse into a walk over that graph. `getMutationSteps` no longer repeats the closure and the filter that `getMutationActions` already performed; both consume one `MutationChainForRead`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…-mutation-read-set-closure
…n a proxy flag Ported from #114561 by Shaohua Wang (tiandiwonder), which added it after the version this branch started from. The warning about a MATERIALIZED column derived from an EPHEMERAL one keeping a stale on-disk value was keyed on `recalculate_dependencies_of_updated_columns`. That flag is cleared on two paths, not one: the on-fly read, which writes nothing and should stay quiet, and `MergeTreeData::updateLightweightImpl`, which builds a patch part and does write. Keying on it silenced the one diagnostic a lightweight `UPDATE` gives. Say what is meant with `Settings::apply_on_fly_for_read`, set only where `AlterConversions` builds the actions for reading a part. `05023_materialized_ephemeral_stale_warning` is taken unchanged from that pull request and asserts all three directions at once. Measured against this build: `ALTER TABLE ... UPDATE` warns, a lightweight `UPDATE` warns, an on-fly read does not and still returns the stale value the warning is about. Co-Authored-By: Shaohua Wang <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [9222457] Summary: ✅
AI ReviewSummaryThis PR fixes several PR Metadata
Missing context / blind spots
Findings
Final VerdictNeeds changes before merge: the correctness fix looks good, but the dependency cache should not eagerly re-analyze every LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 151/155 (97.42%) · Uncovered code |
| source_columns.push_back(column); | ||
| } | ||
|
|
||
| for (const auto & column : columns) |
There was a problem hiding this comment.
This helper is eager right now: constructing it walks every MATERIALIZED default in the table and runs TreeRewriter on each one. The two new call sites build it on hot paths (MutationsInterpreter::prepare per part and AlterConversions::getMutationSteps per read task), and prepare does so even before need_materialized_analysis is known. On a wide table, even a DELETE-only pending mutation or a query that reads a single derived column now pays O(all MATERIALIZED columns) analyzer work before the read starts.
Can we make the entries lazy per column, or at least defer construction until materialized analysis is actually needed and limit it to the columns reachable from the current read set?
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes14 object files changed (+58.72 KiB total), 1 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units364 translation units recompiled, 3621 s compile time in total, 363 of them have a recent master baseline. |
…h from #115638 Avogar tried an alternative on top of this branch in #115638 and asked for it to be moved here. This is that change, applied verbatim: the four test files this branch already carried are byte-identical in it, and `Settings::apply_on_fly_for_read` is kept. What it adds over what was here: - `MaterializedColumnDependencies` — the dependency graph over a table's `MATERIALIZED` columns, built once and shared by the read path and `MutationsInterpreter` instead of being derived separately in each. `getAffected` closes over the graph, so a column reachable only through another recomputed one is included. - `filterMutationCommands` puts the columns a surviving command reads into the read set, and one of those can itself be a `MATERIALIZED` column of a chain (`DELETE WHERE m2 > 100`), which can in turn keep an older command alive. Closing the set and filtering now run in a loop until the set stops growing; it only grows and is bounded by the width of the table, so it terminates. - A command may name a subcolumn as written (`t.a`) while the read set is keyed on storage columns, which made every read of the table fail with `NO_SUCH_COLUMN_IN_TABLE`. Names now go through `getNameInStorage` on the way in. This one reproduces on master. - `getMutationSteps` and `getMutationActions` share one `buildMutationChainForRead` instead of each recomputing the read set and the command filter. Test `04926_on_fly_mutation_read_set_closure` covers the chain reached from a pending `DELETE` predicate, the subcolumn spelling, and the cases that must not move. Co-authored-by: avogar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Workflow [PR]
Sync PR [sync-upstream/pr/115638]