Skip to content

Reject a Nil INNER UUID in a TimeSeries target clause - #130698

Merged
nikitamikhaylov merged 1 commit into
ClickHouse:masterfrom
groeneai:time-series-reject-nil-inner-uuid
Nov 11, 2026
Merged

nikitamikhaylov merged 1 commit into
ClickHouse:masterfrom
groeneai:time-series-reject-nil-inner-uuid

Conversation

@groeneai

@groeneai groeneai commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Improvement

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

An INNER UUID clause of a TimeSeries table target now rejects the Nil UUID with BAD_ARGUMENTS, as TO INNER UUID already does, instead of silently ignoring the clause.

Description

A debug server aborts with Logical error: 'Inconsistent AST formatting' (STID 1941-1bfa) on CREATE TABLE t ENGINE = TimeSeries RECENT SAMPLES INNER UUID '00000000-0000-0000-0000-000000000000'. La Casa Del Dolor (amd_debug) sent this statement: job report.

Root cause: ParserViewTargets creates its ASTViewTargets result and then calls setInnerUUID, which records only a non-Nil UUID. So a Nil INNER UUID leaves an empty ViewTargets child on the CREATE query. The formatter prints nothing for it, the reparsed query has no such child, and the tree hashes differ. Release builds silently ignore the clause (26.8.18.2 and 26.10.3.7 format the statement as CREATE TABLE t ENGINE = TimeSeries).

Change: reject a Nil <kind> INNER UUID at parse time with BAD_ARGUMENTS, the same way #114171 did for TO INNER UUID and ATTACH ... UUID. ParserViewTargets is the only remaining INNER UUID parse site, and only the TimeSeries engine clause uses it. The server never writes such a clause into metadata (ASTViewTargets::formatTarget prints INNER UUID only for a non-Nil value), so existing tables attach as before.

Validation: the new test 05620_time_series_nil_inner_uuid covers every target kind, including the DATA and METRICS aliases. It aborts an unfixed debug server and passes 50/50 with randomized settings on the fixed one. 257 TimeSeries, AST JSON and INNER UUID tests give the same results before and after the change.


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

Version info

  • Merged into: 26.11.1.1983-master (included in 26.11 and later)

`CREATE TABLE t ENGINE = TimeSeries <kind> INNER UUID '00000000-0000-0000-0000-000000000000'`
made `ParserViewTargets` create an `ASTViewTargets` and then drop the Nil UUID
(`ASTViewTargets::setInnerUUID` only records a non-Nil one), so the query carried an
empty `ViewTargets` child that formatting cannot print. The debug round-trip check in
`executeQuery` then threw `Inconsistent AST formatting` and aborted the server
(found by La Casa Del Dolor, STID 1941-1bfa). In release builds the clause was a
silent no-op.

Reject a Nil `<kind> INNER UUID` at parse time with BAD_ARGUMENTS, the same way
`TO INNER UUID` and `ATTACH ... UUID` already reject Nil since ClickHouse#114171. Server-written
metadata never contains such a clause (`ASTViewTargets::formatTarget` prints
`INNER UUID` only for a non-Nil value), so stored tables are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own cold review (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 Category should be Bug Fix, since releases silently ignored the clause DISAGREE On 26.8.18.2 and 26.10.3.7 a Nil INNER UUID is dropped, which is the same as omitting it (setInnerUUID treats Nil as unset), so no release did anything wrong; new validation is Improvement
2 💡 The AST JSON path (ASTViewTargets::readJSON) still accepts a Nil inner_uuid noted Different load path, no round-trip check there, Nil equals unset; not raised
3 💡 The test covers METRIC FAMILIES only through its METRICS alias noted Same parse function for both keywords; no change

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261111-060500

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. clickhouse local -q "CREATE TABLE t ENGINE = TimeSeries RECENT SAMPLES INNER UUID '00000000-0000-0000-0000-000000000000'" on a debug master build aborts every time (Inconsistent AST formatting, signal 6).
b Root cause explained? ParserViewTargets creates the ASTViewTargets result before setInnerUUID, which skips a Nil UUID, so the query keeps an empty ViewTargets child that the formatter cannot print; the reparsed tree has no such child and the hashes differ.
c Fix matches root cause? Yes. The parser rejects a Nil <kind> INNER UUID before creating the result, so the unprintable tree is never built. Nothing is guarded at the formatter or the check.
d Test intent preserved / new tests added? New 05620_time_series_nil_inner_uuid: every target kind, the DATA and METRICS aliases, and a kind that already has a table name.
e Both directions demonstrated? Yes. The new test kills an unfixed debug server and passes on the fixed one; 50/50 with randomized settings.
f Fix is general across code paths? Yes. All keywords go through one function. The other INNER UUID parse sites (TO INNER UUID, two places) and ATTACH ... UUID already reject Nil (#114171).
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. The check compares the parsed value, so the dashless Nil spelling is rejected too; non-Nil UUIDs and mixed clause sets format exactly as before.
h Backward compatible? (maintainer-approved exception only) Yes. Only an explicit Nil clause changes, which released versions ignored and the server never writes into metadata (formatTarget prints only a non-Nil UUID).
i Invariants and contracts preserved? Yes. The throw happens before any state change; a parsed CREATE no longer carries target state that formatting cannot print.

Session id: cron:clickhouse-impl-slot-40:20261111-053600

@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0feef2a]

Summary: ✅


AI Review

Summary

Rejects explicit Nil INNER UUID clauses on TimeSeries targets with BAD_ARGUMENTS, preventing an empty ASTViewTargets from causing an AST formatting exception. No actionable findings. The focused regression test passed in Fast test CI.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements can be tested Allows running workflows for external contributors comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... labels Nov 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 0feef2aac with master f9e6c60e7 (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.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.73, programs/clickhouse-keeper ×0.72 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 6.8 s 16.4 s +11.5 s (+231%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.9 s 9.0 s +6.1 s (+214%)
Compile time of recompiled translation units

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

Job report

@nikitamikhaylov nikitamikhaylov self-assigned this Nov 11, 2026
@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Nov 11, 2026
Merged via the queue into ClickHouse:master with commit 65ddb52 Nov 11, 2026
551 of 553 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... pr-improvement Pull request with some product improvements 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.

3 participants