Skip to content

Recompute MATERIALIZED columns when a column TTL resets their source - #117815

Merged
alexey-milovidov merged 12 commits into
masterfrom
recompute-materialized-columns-after-column-ttl-117310
Oct 1, 2026
Merged

alexey-milovidov merged 12 commits into
masterfrom
recompute-materialized-columns-after-column-ttl-117310

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

When a column TTL expires, the merge resets the source column to its default but left the MATERIALIZED columns computed from it untouched, so they kept the value derived from the pre-expiry data forever - no later merge repairs it, and the column contradicts its own expression:

CREATE TABLE t (d DateTime, x Int32 TTL d + INTERVAL 1 SECOND, mk Int32 MATERIALIZED x + 1)
ENGINE = MergeTree ORDER BY tuple() SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO t (d, x) VALUES (now() - 3600, 41);

OPTIMIZE TABLE t FINAL;
SELECT x, mk FROM t;   -- 0, 42 (was 41, 42): x expired, mk kept the stale value

ALTER TABLE ... CLEAR COLUMN, the other path that resets a column to its default, already recomputes dependent MATERIALIZED columns.

TTLTransform now recomputes them over MaterializedColumnDependencies - the same dependency graph UPDATE, CLEAR COLUMN, APPLY PATCHES and AlterConversions use, which expands ALIAS references, reports a dependency on a subcolumn as one on the whole column, and leaves out a column that reads an EPHEMERAL one, which no part holds. The set is closed transitively, because a dependent may read another dependent (m2 MATERIALIZED m1 + 1) and has to see its recomputed value, and the recomputation is interleaved with the column TTL algorithms: the TTL of a column nothing recomputes runs first, then the dependents level by level, and the own TTL of a dependent runs right after the level that recomputed it, so its reset wins row by row over the recomputed value. TTLAggregationAlgorithm flushes the rows of a GROUP BY TTL at the end of the part, after the last block was consumed, so both entrypoints go through the same step.

Left alone are a dependent that is not deterministic (recomputing would also change the rows the TTL did not touch), one that is already expired for the whole part (recomputing would undo the expiry), and one that takes part in the sorting, primary or partition key (recomputing would invalidate the order of the part being written). Nothing changes such a column, so the dependents reading it keep the value they already have and stay consistent with it.

ALTER TABLE ... MATERIALIZE TTL reads and writes the dependents as well now. It is the command that applies a column TTL to a part no merge is going to touch, and it used to read only the TTL targets and the TTL expressions, so on a single-part table the dependents stayed stale indefinitely. The read set covers the columns a dependent's expression reads next to the expired one (y of m MATERIALIZED x + y), and the dependents take part in the closure the skip index, projection and statistics rebuild is keyed on, so an artifact over a recomputed column is rebuilt and the columns it reads are in the block rather than filled with a type default.

Rebuilding those artifacts also had to move. The mutation pipeline evaluated the skip index expressions into the block before the TTL transform, and the writer reuses whatever expression column it finds there, so an index over a recomputed column was written from the pre-expiry value and then pruned granules that do match - INDEX i m * 2 TYPE minmax over m MATERIALIZED x + 1 answered 0 where a scan answers 1. Both mutation paths materialize their index expressions after the TTL now. The merge pipeline never had the precomputation and was not affected.

A MATERIALIZED expression that is not defined on the default of a column it reads has no correct value once the TTL resets that column, and the error propagates: the merge fails rather than writing a value that contradicts the expression. mk MATERIALIZED intDiv(100, x) next to x TTL ... is such a schema, and it is already one that rejects an INSERT of x = 0 and whose ALTER TABLE ... CLEAR COLUMN x fails the same way, leaving the mutation in the queue. This is a behaviour change for a table whose TTL merge succeeds today with a stale value, and the test pins it.

Closes: #117310

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

A MATERIALIZED column computed from a column with a TTL is now recomputed when the TTL resets that column, both during a merge and in ALTER TABLE ... MATERIALIZE TTL. Previously it kept the value computed before the expiry forever. If the dependent expression is not defined on the expired column's default (for example intDiv(100, x) when x expires to 0), the TTL merge now throws instead of writing the stale pre-expiry value; make the expression total on the default (intDivOrZero, if(x = 0, ...)) if such an existing table must keep merging. This fixes #117310.


Workflow [PR]
Sync PR [sync-upstream/pr/117815]

Version info

  • Merged into: 26.10.1.1228-master (included in 26.10 and later)

When a column TTL expires, the merge resets the source column to its default but left the
`MATERIALIZED` columns computed from it untouched, so they kept the value derived from the
pre-expiry data forever - no later merge repairs it, and the column contradicts its own
expression. `ALTER TABLE ... CLEAR COLUMN`, the other path that resets a column to its
default, already recomputes dependent `MATERIALIZED` columns.

`TTLTransform` now recomputes, after the TTL algorithms have run, the `MATERIALIZED`
columns whose expression reads a column with a TTL. The expressions are evaluated on the
post-TTL block, so a row that did not expire keeps its value. Left alone are a dependent
that is not deterministic (recomputing would also change the rows the TTL did not touch),
one that has a TTL of its own (the TTL has just reset it), and one that takes part in the
sorting, primary or partition key (recomputing would invalidate the order of the part being
written).

The mutation pipeline of `ALTER TABLE ... MATERIALIZE TTL` reads only the columns it
rewrites, so a dependent that is not in its block is recomputed by the next merge instead.

Closes: #117310
@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [36f6762]

Summary: ✅


AI Review

Summary

This PR fixes the stale MATERIALIZED-column problem after column-TTL resets, extends ALTER TABLE ... MATERIALIZE TTL to rewrite the same dependency closure, and moves derived-artifact rebuilds to the post-TTL value flow where needed. I checked the current code against the final diff and the full prior discussion, and I did not find a remaining PR-specific blocker or major on the current head.

Missing context / blind spots
  • ⚠️ I did not run local tests in this checkout because no build* directory or built clickhouse binary was present. This review relied on source inspection, the current PR discussion, and the added stateless coverage in 05073-05076 and 05257.
Final Verdict

✅ No new findings.

LLVM Coverage Report

Measured on commit 36f6762.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.50% 79.50% +0.00%

Changed lines: Changed C/C++ lines covered: 146/153 (95.42%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 3, 2026
@zlareb1

zlareb1 commented Sep 3, 2026

Copy link
Copy Markdown
Member

One more leg, not covered by the inline review: a dependent whose expression is not total on the source column's default turns a previously working table into one whose TTL merge always fails.

The recompute at TTLTransform.cpp:262 runs executeExpressionAndGetColumn on the post-reset block with no exception containment, so any dependent expression that throws on the default value (intDiv, modulo, a strict arrayElement, a throwing conversion) makes the whole merge throw:

CREATE TABLE tb (d DateTime, x Int32 TTL d + INTERVAL 1 SECOND, mk Int32 MATERIALIZED intDiv(100, x))
ENGINE = MergeTree ORDER BY tuple();
INSERT INTO tb (d, x) VALUES (now() - 3600, 41);  -- mk = 2, fine
OPTIMIZE TABLE tb FINAL;

Verified on this PR's CI binary (26.9.1.1, head 39dbc94, build_arm_release): the OPTIMIZE throws Code: 153. DB::Exception: Division by zero: while executing 'FUNCTION intDiv(100 :: 1, x :: 0) -> intDiv(100, x)': While executing TTL. (ILLEGAL_DIVISION). On current master the same statements succeed (with the stale mk, which is the bug being fixed — but the merge completes). Since the part keeps a part_min_ttl in the past, every retry of the merge hits the same exception: the background merge loop retries forever, the TTL is never applied, and on Replicated* engines the merge entry blocks the queue. ALTER TABLE ... CLEAR COLUMN has the same recompute-and-throw semantics, but that is a one-shot foreground action, not an unavoidable background loop, and it does not start firing on existing schemas after an upgrade.

A contained fallback would preserve the fix without the regression: catch the exception per dependent, keep the stored (stale) column for that block, and log a warning — the same stale-tolerant treatment the PR already gives its disclosed exclusions.

On the chain case the inline review already flags (m1 MATERIALIZED x + 1, m2 MATERIALIZED m1 + 1): it is slightly worse than "m2 stays stale". Before this PR the stored pair still satisfied m2 = m1 + 1 (both were computed at insert and both left untouched); after it, the same repro yields x = 0, m1 = 1, m2 = 43, so m2 now contradicts its own stored input, and permanently — later TTL merges recompute m1 idempotently and never m2 (verified on the same binaries: pre-PR 0, 42, 43, PR head 0, 1, 43). So the transitive closure is needed for the fix not to introduce a new inconsistency, not just to finish the old repair.

@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 36f676246 with master aed775756 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

6 object files changed (+64.57 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Transforms/TTLTransform.cpp.o 220.45 KiB 280.32 KiB +59.88 KiB (+27.16%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

10 translation units recompiled, 65 s compile time in total, 10 of them have a recent master baseline.

Job report

@clickhouse-gh clickhouse-gh Bot added the comp-ttl TTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts). label Sep 4, 2026
…ency order

The recomputation `TTLTransform` gained selected only the columns whose own expression reads a
column a TTL resets, reanalysed the raw default AST to find them, and ran after every algorithm
had finished. Three consequences, all reported on the pull request:

- A chain was left half repaired. With `m1 MATERIALIZED x + 1, m2 MATERIALIZED m1 + 1`, `m1` was
  recomputed and `m2` was not, so `m2` no longer even matched its own stored input - before, the
  two at least agreed with each other.
- A dependent reading the expired column through an `ALIAS`, or reading a subcolumn of it, never
  matched: the analysis was keyed on the raw carriers, so `reset_columns` held `x` and `t` while
  the required columns were `a` and `t.a`.
- Every column that has a TTL of its own was skipped table-wide, although only the rows whose own
  TTL was due had been reset. Which value such a column ended up with also depended on the order
  `getColumnTTLs` happened to return, because that decided whether its algorithm ran before or
  after the one that resets the column it reads.

The analysis is `MaterializedColumnDependencies` now - the graph `UPDATE`, `CLEAR COLUMN`,
`APPLY PATCHES` and `AlterConversions` already share, which expands `ALIAS` references, reports a
dependency on a subcolumn as one on the whole column, and leaves out a column reading an
`EPHEMERAL` one, which no part holds. `findColumnsToRecalculate` closes the set transitively.

The dependents are grouped into levels, a column of level `i` reading only columns of the lower
levels, and the recomputation is interleaved with the column TTL algorithms: the TTL of a column
nothing recomputes runs first, then the levels in order, and the own TTL of a dependent runs right
after the level that recomputed it, so its reset wins row by row over the recomputed value.

`TTLAggregationAlgorithm` emits the last group it accumulated from `generate`, after the last block
was consumed, and the column TTL algorithms reset their columns in that block too, so `consume` and
`generate` go through the same `executeAlgorithms`.

Left alone are a dependent that is not deterministic, one that is already expired for the whole
part, and one that takes part in the sorting, primary or partition key. Nothing changes such a
column, so the dependents reading it keep the value they already have and stay consistent with it.
…LIZE TTL`

For a table whose only TTL is a column TTL, the mutation read the TTL targets and the columns the
TTL expressions need, so a `MATERIALIZED` column computed from an expiring column was not in the
block and `TTLTransform` could not rewrite it. Leaving it to the next merge is not enough: this is
the command that applies a column TTL to a part no merge is going to touch, and once it has run the
part records the TTL as applied, so on a single-part table the stale value stayed there for good.

The transitive closure comes from the same `MaterializedColumnDependencies` the rest of the file
uses, restricted to the columns the part holds, and enters `dependencies` as `TTL_TARGET`, which is
what makes the mutation read and write them.
…`05073`

One case per leg the review asked for, each of which the pull request's earlier head got wrong:

- A three-hop chain: `0 1 2 3`, where it used to give `0 42 43 44`.
- A dependent with a TTL of its own that is not due for the row whose source expired: `0 1`, where
  it used to give `0 42`.
- A dependent reading the expired column through an `ALIAS` and one reading a subcolumn of an
  expiring `Tuple`: `101` and `1`, where they used to give `142` and `8`.
- A `GROUP BY` TTL whose last group is emitted at the end of the part rather than from a consumed
  block: `m = 1`, where it used to give `43`. That case has to use a column TTL that is only
  partially due, because a `GROUP BY` TTL next to a column TTL expired for the whole part throws
  `NOT_FOUND_COLUMN_IN_BLOCK` before any of this runs, with no `MATERIALIZED` column involved -
  a separate bug.
- A `MATERIALIZED` expression that is not defined on the default of the column it reads
  (`intDiv(100, x)`), which has no correct value after the expiry: the merge reports
  `ILLEGAL_DIVISION` rather than writing a value that contradicts the expression. The same schema
  already rejects an `INSERT` of `x = 0` and fails `ALTER TABLE ... CLEAR COLUMN x` the same way.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @zlareb1 thank you - both legs you raised are handled, one by fixing it and one by keeping it and saying so out loud.

The chain. You are right that it was worse than "m2 stays stale": the pull request made m2 contradict its own stored input, which the pre-PR pair at least did not. The recomputation goes through MaterializedColumnDependencies now - the graph UPDATE, CLEAR COLUMN, APPLY PATCHES and AlterConversions already share - so the set is closed transitively and evaluated in dependency order. Your repro is in 05073 as a three-hop chain and gives 0 1 2 3. That graph also expands ALIAS references and reports a subcolumn read as a dependency on the whole column, so m MATERIALIZED a + 1 over a ALIAS x + 100 and m MATERIALIZED t.a + 1 are covered as well.

The expression that is not total on the default. Kept as it is, deliberately, and 05073 pins it (OPTIMIZE ... FINAL → ILLEGAL_DIVISION) so it cannot regress by accident. Two corrections to the comparison with CLEAR COLUMN, though, because they narrow the gap you describe:

  • It is not only "the same recompute-and-throw semantics, but a one-shot foreground action". On the same schema it is the same kind of stuck loop: ALTER TABLE tb CLEAR COLUMN x with mk MATERIALIZED intDiv(100, x) fails with Code: 341 ... reason: 'Code: 153 ... (ILLEGAL_DIVISION)', and the failed mutation stays in the queue and blocks every later mutation of the table until KILL MUTATION.
  • The schema is already one that cannot hold the value the TTL produces: INSERT INTO tb (d, x) VALUES (now(), 0) throws ILLEGAL_DIVISION on master today. The invariant the expression relies on (x != 0) is broken by the table's own TTL, not by this change.

So the choice is between reporting a schema whose MATERIALIZED column has no defined value after the expiry, and silently storing a value that contradicts the expression - which is the bug being fixed here. I am not hiding the cost: a table that merges today starts failing its TTL merge after an upgrade, and on Replicated* the merge entry blocks the queue until the TTL or the column is dropped or the expression is made total (intDivOrZero, if (x = 0, ...)). The description says so.

Two more things came out of this round:

  • ALTER TABLE ... MATERIALIZE TTL now reads and writes the dependents (1433f5f74335, test 05074). Leaving them to the next merge was not enough - once that command has run, the part records the TTL as applied, so on a single-part table the stale value stayed for good.
  • While writing the GROUP BY TTL case I hit a separate, pre-existing bug, with no MATERIALIZED column involved: a GROUP BY TTL next to a column TTL that is expired for the whole part throws before any of this runs.
CREATE TABLE t (k Int32, d DateTime, x Int32 TTL d + INTERVAL 1 SECOND) ENGINE = MergeTree ORDER BY k
TTL d + INTERVAL 1 DAY GROUP BY k SET x = max(x);
INSERT INTO t VALUES (1, '2000-01-01 00:00:00', 41), (1, '2000-01-02 00:00:00', 42);
OPTIMIZE TABLE t FINAL;
-- Code: 10. DB::Exception: Not found column x in block. There are only columns: k, d. (NOT_FOUND_COLUMN_IN_BLOCK)

MergeTask drops a fully expired column from the input header and only TTLTransform::consume re-inserts the expired_columns with their defaults, so the block flushed from generate never has them and reorderColumns cannot find the column. 05073 therefore uses a partially due column TTL for that case. I will send that fix separately.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Correction to the repro I posted for the pre-existing GROUP BY TTL bug, in the comment above and in this thread: I dropped SETTINGS min_bytes_for_wide_part = 0 from it. Without that the part is compact, TTLColumnAlgorithm takes its per-row path instead of the whole-block one, and the statement succeeds - so the snippet as written does not reproduce. The finding itself stands; the repro is:

CREATE TABLE t (k Int32, d DateTime, x Int32 TTL d + INTERVAL 1 SECOND)
ENGINE = MergeTree ORDER BY k
TTL d + INTERVAL 1 DAY GROUP BY k SET x = max(x)
SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO t VALUES (1, '2000-01-01 00:00:00', 41), (1, '2000-01-02 00:00:00', 42);
OPTIMIZE TABLE t FINAL;
-- Code: 10. DB::Exception: Not found column x in block. There are only columns: k, d. (NOT_FOUND_COLUMN_IN_BLOCK)

Checked on this pull request's own CI binary (26.9.1.1, 83d491e5, build_arm_release), so it is current master and not an artefact of my build. A wide part is required, no MATERIALIZED column is required, and it does not matter whether the expiring column is in the GROUP BY SET list - all four combinations throw. Still a separate bug, still going in its own pull request.

…IALIZE TTL`

`ALTER TABLE ... MATERIALIZE TTL` asked for the dependent `MATERIALIZED` columns of an
expired column, but not for the columns their expressions read next to it, and not through
the closure the skip index, projection and statistics rebuild is keyed on.

So `m MATERIALIZED x + y` with a TTL on `x` alone had no `y` in the block, `TTLTransform`
skipped `m`, and the command rewrote it with the stale value - exactly what it is meant to
repair. And a projection grouping by a column no TTL touches was rebuilt without that
column in the block: `calculateProjection` fills a missing required column with a type
default, so the projection answered with a group key the base table does not have.

The dependents now enter `new_updated_columns` before that closure is taken, and every
column their expressions read is asked for as a read-only dependency.

The rebuild decision itself was already covered: it keys on `changed_columns`, which the
dependents joined as `TTL_TARGET`. What was missing were the columns read next to them.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 A separate defect found while covering this, on the branch as it stands (2e7db471) and not introduced by the read-set fix above: after ALTER TABLE ... MATERIALIZE TTL, a skip index whose expression is a computed expression over a recomputed MATERIALIZED column is written so that it prunes away the granule that does hold the row.

CREATE TABLE t (d DateTime, x Int32, m Int32 MATERIALIZED x + 1, INDEX i m * 2 TYPE minmax GRANULARITY 1)
ENGINE = MergeTree ORDER BY tuple()
SETTINGS min_bytes_for_wide_part = 0, materialize_ttl_recalculate_only = 0;
INSERT INTO t (d, x) VALUES ('2000-01-01 00:00:00', 41);

SET materialize_ttl_after_modify = 0;
ALTER TABLE t MODIFY COLUMN x Int32 TTL d + INTERVAL 1 SECOND SETTINGS mutations_sync = 2;
ALTER TABLE t MATERIALIZE TTL SETTINGS mutations_sync = 2;

SELECT x, m, m * 2 FROM t;                                          -- 0  1  2, so the data is right
SELECT count() FROM t WHERE m * 2 = 2 SETTINGS use_skip_indexes = 0; -- 1
SELECT count() FROM t WHERE m * 2 = 2;                               -- 0  <-- the index prunes it

EXPLAIN indexes = 1 shows Granules: 0/1 for i. Bracketing the stored range with >= / <= gives an inverted one (max in [501, 504], min in [506, 550] on the m + w variant), which is what an aggregator that received no rows writes - so the granule is written empty rather than stale.

What discriminates, all on the same binary:

index expression column TTL applied by result
m (bare column, MATERIALIZED) MATERIALIZE TTL correct
(m, w) (bare columns) MATERIALIZE TTL correct
x + w (computed, plain TTL target) MATERIALIZE TTL correct
m + w / m * 2 (computed, MATERIALIZED) merge (OPTIMIZE FINAL) correct
m + w / m * 2 (computed, MATERIALIZED) MATERIALIZE TTL empty index

So it needs all three of: the mutation path, a non-trivial index expression, and a column that TTLTransform (not a mutation stage) rewrites. An ALTER TABLE ... UPDATE that recomputes the same m through the interpreter's own recompute stage leaves the index correct, which points at the index-recalc ExpressionTransform that updateIndicesToRecalculateAndDrop inserts into mutating_pipeline_builder before TTLTransform is appended - but I could not confirm the mechanism, because the stale precomputed value would have produced a stale range, not an empty one.

Verified on the branch with the fix reverted, so it comes from 1433f5f74335 (which is what starts rebuilding artifacts over these columns at all) and is independent of the read-set change. Before that commit the index was not rebuilt here, so it stayed consistent with the equally stale m.

05075 therefore covers only the two legs that are correct - the extra expression input and the projection group key - and leaves the skip index out rather than pinning the wrong answer. This wants its own fix before merge, since it silently drops rows from a query.

…ot before

The mutation pipeline evaluated the skip index expressions into the block before the TTL transform,
and the writer reuses whatever expression column it finds there rather than evaluating it itself. So
once `MATERIALIZE TTL` started recomputing the `MATERIALIZED` columns of an expired column, an index
over one of them was written from the pre-expiry value while the part stored the new one, and the
index then pruned granules that do match:

```sql
CREATE TABLE t (d DateTime, x Int32, m Int32 MATERIALIZED x + 1, INDEX i m * 2 TYPE minmax GRANULARITY 1)
ENGINE = MergeTree ORDER BY tuple() SETTINGS min_bytes_for_wide_part = 0, materialize_ttl_recalculate_only = 0;
INSERT INTO t (d, x) VALUES ('2000-01-01 00:00:00', 41);

SET materialize_ttl_after_modify = 0;
ALTER TABLE t MODIFY COLUMN x Int32 TTL d + INTERVAL 1 SECOND SETTINGS mutations_sync = 2;
ALTER TABLE t MATERIALIZE TTL SETTINGS mutations_sync = 2;

SELECT x, m FROM t;                                     -- 0, 1
SELECT count() FROM t WHERE m * 2 = 2 SETTINGS use_skip_indexes = 0;   -- 1
SELECT count() FROM t WHERE m * 2 = 2 SETTINGS use_skip_indexes = 1;   -- 0, the index says [84, 84]
```

Both mutation paths did it. The one that rewrites every column materialized
`getPrimaryKeyAndSkipIndicesExpression` ahead of the TTL transform, so that block is moved after it.
The one that rewrites some of them appends its expressions where it decides which indices to
recalculate, which is before the task builds the rest of the pipeline, so the expression list is
carried on the context and materialized after the TTL instead.

The merge pipeline was never affected: it has no such precomputation, and its writer evaluates the
index expressions on the block the TTL has already worked on.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (the branch was 3843 commits behind) as e9c2fcc. No conflicts. The single red of f1ddfdb, Upgrade check (amd_release) with the logical error Virtual row has different type for CAST(__table1.json.b, 'String') in setVirtualRow, is the read-in-order virtual-row bug fixed on master by #119195, so the merge pulls the fix in. All four new tests (05073-05076) pass locally on the merged branch.

Following the AI review's metadata finding, the changelog category is now Backward Incompatible Change and the entry names the new failure mode for a dependent expression that is not total on the expired column's default. The behaviour itself stays as decided in #117815 (comment).

@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes and removed pr-bugfix Pull request with bugfix, not backported by default labels Sep 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 36 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 2c271fee-dbfa-4cc9-bfb0-dfffdf5fa89c
  • MIRAI run: 66b72859-d8b1-4fbd-8b1a-c63c7e4d1a10
  • PR check IDs:
    • clickbench_2678893_1790835749
    • clickbench_2678899_1790835750
    • clickbench_2678906_1790835749
    • tpch_adapted_1_official_2678935_1790835750
    • tpch_adapted_1_official_2678949_1790835749
    • tpch_adapted_1_official_2678963_1790835750

alexey-milovidov and others added 2 commits September 25, 2026 13:58
…zed-columns-after-column-ttl-117310

# Conflicts:
#	src/Storages/MergeTree/MutateTask.cpp
…ATERIALIZE TTL`

A review asked whether the some-columns `MATERIALIZE TTL` path rebuilds the
statistics of the `MATERIALIZED` columns recomputed after a column TTL. It does:
the recomputed columns enter as `TTL_TARGET` dependencies, which are not
read-only, so they land in `changed_columns` and the loop at the end of
`MutationsInterpreter::prepare` puts them into `materialized_statistics`.
Pin that with a test on a wide part that is mutated through
`MutateSomePartColumnsTask`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Oct 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 1, 2026
Merged via the queue into master with commit 3b05333 Oct 1, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the recompute-materialized-columns-after-column-ttl-117310 branch October 1, 2026 23:53
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 2, 2026
Ergus pushed a commit to Ergus/ClickHouse that referenced this pull request Nov 6, 2026
The leaked merge is retried without end on both the old and the upgraded
server because of issue ClickHouse#123953: the recompute of a MATERIALIZED column
added by ClickHouse#117815 throws inside every background TTL merge. The entry does
not fix that issue and only matches this fixture's string.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-ttl TTL rules and TTL merges (moving/recompressing/rolling-up/deleting parts). pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Column TTL resets the source column to its default without recomputing dependent MATERIALIZED columns — permanently stale values

3 participants