Repository navigation
Refuse the Quantized codec in Log, TinyLog and Buffer tables - #127795
shankar-iyer merged 5 commits into
Conversation
An INSERT into a Log or TinyLog table with a `Quantized('product')` column
failed with LOGICAL_ERROR "Stream was not created when writing data in
LogSink" (abort in debug builds, stack-use-after-scope under ASan).
`LogSink::onFinish` passes a temporary `NameAndTypePair` to
`createStreamGetter`, whose closure captured it by reference, so the getter
read a destroyed object when `SerializationQuantizedVector` wrote the
per-part codebook in `serializeBinaryBulkStateSuffix`. Capture it by value.
With that fixed, the insert succeeds but the data cannot be read back
correctly: LogSink writes one codebook per INSERT, while LogSource reads it
once per source and broadcasts it, the same limitation that already makes
Log refuse Variant. Measured on a build with only the capture fix: after two
inserts, `vec.product_quantization_codebook` returns the first insert's
codebook for the second insert's rows (MergeTree returns two codebooks), and
on TinyLog a codebook read of a 4-row table returns 65409 rows.
So Log and TinyLog refuse a column with this serialization with
ILLEGAL_COLUMN for a fresh definition (CREATE, CREATE AS, CREATE AS SELECT,
full-definition ATTACH), and `write` refuses INSERT for every table, so a
definition stored by an older server still loads and can be dropped. The
refusal checks the column's serialization over its type tree rather than
its codec, because a column inferred by `CREATE ... AS SELECT` keeps the
serialization of the source column without its codec. The data-independent
methods are unaffected.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rewrite the checkSupportedCodecs comment as a standalone invariant, dropping the narration of the check below it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 findings over 3 rounds, the last round clean) plus my own review (3 findings).
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20261025-222500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261025-221800 |
|
cc @Avogar @shankar-iyer, could you review this and add the |
|
Workflow [PR], commit [15a5c42] Summary: ✅
AI ReviewSummaryThe PR refuses Final VerdictStatus: ✅ Approve. |
In a Replicated database, CREATE TABLE ... AS SELECT is replicated as a
formatted query with an explicit column list, so the new table is created
from that list and does not inherit the Quantized('product') serialization
of the source column. The table is then a plain Array(Float32) table, which
is correct, but the five ILLEGAL_COLUMN expectations failed in the
DBReplicated stateless job. The arms now create their tables in a dedicated
Atomic database, so they check the inferred-type path in every lane.
A populated AS SELECT is also refused by the check in StorageLog::write, so
those arms cannot tell whether the CREATE check fired. Two EMPTY AS SELECT
arms (top-level on Log, nested on TinyLog) skip the insert and pin the
CREATE check itself.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 10807b4Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261028-013006 |
|
@shankar-iyer Could you check this one please if you have time? |
Review feedback on ClickHouse#127793 and ClickHouse#127795: refuse the Quantized codec in Buffer the same way as in Log and TinyLog, for every method rather than only `product`. Buffer: a `product` column read a subcolumn of buffered rows that the buffer cannot produce, so `SELECT vec.quantized` from a Buffer with unflushed rows aborted with LOGICAL_ERROR "Column or subcolumn 'vec.quantized' not found in Buffer table" (AST fuzzer, arm_asan_ubsan: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=121674&sha=660cb5a2ee&name_0=PR). A fresh Buffer definition (explicit columns, `AS <table>`, a structure inferred from the destination, full-definition ATTACH) is now refused with ILLEGAL_COLUMN, and so is `ALTER ... ADD/MODIFY COLUMN` with the codec. The ALTER check looks at the codec, because MODIFY COLUMN sets the codec without attaching its serialization. Log and TinyLog now refuse every method, not only `product`. The check in `StorageLog::write` is removed: it existed only for definitions stored by older servers, which are replayed without the CREATE check, and with every method refused it would also break inserts into `int8` Log tables that work today. The by-value capture in `LogSink::createStreamGetter` stays. Closes ClickHouse#118714 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quantized('product') codec in Log and TinyLog tablesQuantized codec in Log, TinyLog and Buffer tables
The Buffer case of 02184 infers its structure from a Merge table whose `vec` column carries the Quantized codec of one source table. Buffer now refuses any Quantized codec, so that CREATE fails with ILLEGAL_COLUMN (Fast test on c38a612). Distributed and Remote still cover the inherited-TTL case over the same Merge table. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units13 translation units recompiled, 66 s compile time in total, 13 of them have a recent master baseline. |
Closes: #118714
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Log,TinyLogandBuffertables now refuse a column with the experimentalQuantizedcodec withILLEGAL_COLUMN.Description
The
Quantizedcodec does not work with these engines:Log/TinyLog: on 26.8, 26.9 and 26.10, everyINSERTinto a table with aQuantized('product', ...)column fails withLOGICAL_ERROR: Stream was not created when writing data in LogSink(a debug-build abort,stack-use-after-scopeunder ASan), becauseLogSink::createStreamGettercaptured a temporaryNameAndTypePairby reference. It now captures it by value. Even with that fixed,Logwrites the codebook per insert but reads it once per source, the same limitation that makes it refuseVariant.Buffer: reading the codes of buffered rows fails, because buffered rows have no codebook. Found by the AST fuzzer (report):These engines now refuse every
Quantizedmethod withILLEGAL_COLUMNfor a fresh definition (CREATE,CREATE ... AS,CREATE ... AS SELECT, full-definitionATTACH, and forBufferalso a structure inferred from the destination) and, forBuffer, onALTER ... ADD/MODIFY COLUMNwith the codec. A table stored by an older server still loads.02184_storage_add_support_ttlnow expects this for itsBufferover aMergetable with the codec.The test fails on master and on the previous head of this PR, which refused only
product, and passes with the fix (50/50 randomized runs, also with--replicated-database); removing any of the three checks makes it fail. Tables created on master load with the fix, and inserts into theirint8Logtables keep working. Not for changelog: the codec is experimental (enable_quantized_codec).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127795]
Version info
26.11.1.2404-master(included in26.11and later)