Repository navigation
Conversation
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 11 review passes over this branch,
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20260801-145000 |
Pre-PR validation gate (a-i)
Session id: cron:clickhouse-impl-slot-43:20260801-060002 |
|
cc @Avogar @CurtizJ, could you review this? An |
|
Workflow [PR], commit [32fdcea] Summary: ✅
AI ReviewSummaryReviewed head Final Verdict✅ Approve |
|
Pushed
Measured both directions on a debug build before removing it, so the oracle is not weakened:
One note on the unit tests: I could not run Session id: cron:clickhouse-maint-slot-17:20260801-165500 |
The per-granule path names were appended to the caller's list in one range insert after the checkpointed read loop, so the delay this PR removes was still bounded by the sum of all name lengths in the granule, times the number of buckets, rather than by a constant. Same shape as the dynamic-path range insert already expanded in SerializationObject.cpp. Compact reads a function-local granule, so the names are moved and the span disappears. Wide can get granules from the substreams cache shared with other columns reading the same shared data, so there the names must still be copied and the loop is checkpointed instead. Reported by the automated reviewer on ClickHouse#112918. The other sites it flagged are already bounded per name: dynamic_paths is a set of string_view, so its insert only hashes, and the statistics and position_to_requested_path inserts each sit inside a loop that already checkpoints per iteration.
eb9eef0 to
4a55afe
Compare
|
Both comments make the same quantitative claim, so I measured it rather than argue from reading. One of the four sites was real and is fixed in Constructibility first. A path name that large is reachable, so I did not treat it as hypothetical: Magnitude. One hash or one copy of a single name,
Against the failure this PR fixes (
The statistics maps, and The compact paths.insert(paths.end(), structure_granule.all_paths.begin(), structure_granule.all_paths.end());It is a range insert, so its span is the whole granule's path list rather than one name; the enclosing The names are now moved instead of copied, one at a time under the checkpoint. Moving is also correct here rather than merely faster: A move is a pointer swap per name regardless of length, which is why the remaining bound is the throttle period and not the path count: 50000 names of 1 MiB each, 50 GiB of bytes, transfer in 0.736 ms, against 0.641 ms for the same count at 64 bytes. Verified both directions on a debug build: the regression test is green, and with the two reader guards removed it reddens exactly the part-check cells (compact 16, wide 10). The Two unrelated fixes came out of the same review: the test now carries The 17 commits are squashed into one, with no content change. |
CI finish ledger - 4a55afeEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task CI is complete at this head: 174 of 174 check runs report
On the first line, the reason is measured rather than asserted, because "a
I have not touched #109000. The fix task will open its own PR and link it here. Session id: cron:clickhouse-maint-slot-14:20260801-234200 |
Fixing-PR link for the
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes8 object files changed (+50.80 KiB total), 1 added.
719 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 units13 translation units recompiled, 85 s compile time in total, 12 of them have a recent master baseline. |
A SELECT cancelled while a reader is inside an Object/JSON structure-prefix read kept running to completion, and the readers' catch-all then reported the part broken. A cancellation says nothing about a part's health, so the part was suspected on the basis of the client going away. Observed as a hung check on a Stress test job, where a cancelled `select json.a` sat for 594 seconds with `is_cancelled = 1` and `read_rows = 0`. The structure prefix is decoded in one uninterruptible stretch: path names, the path list, per-path statistics and the shared-data prefix are read without ever consulting the query state, so the read only ends when the stream does. This adds cancellation checkpoints along that decode, and suppresses the broken-part report for a failure that is a cancellation rather than a corruption, in the Compact and Wide readers. Two counts read from a possibly untrusted stream are also bounded before they size anything: a path count is capped for the `reserve` hint while the read loop still grows the container on demand, so a corrupted over-count fails as a normal short read instead of a multi gigabyte allocation, and a V3 bucket count is rejected outside the range its writer-side setting can produce. Covered by a gtest for the serialization layer and by a stateless test that cancels a read of both a Compact and a Wide part and asserts that the part is neither reported nor invalidated. The stateless test times its own fixture through query_log rather than with in-query clock reads, because with the old analyzer a subquery whose result is unused is removed before execution, which would leave every cancellation budget at the floor; a run that cannot measure its fixture fails rather than proceeding uncalibrated. Both tests fail on a pre-fix binary.
408de4f to
763e3ea
Compare
`Style check` / `various` failed on this test: `various_checks.sh` requires every query against `system.query_log` to carry a `current_database = currentDatabase()` predicate, and the calibration read added in the previous round did not. The predicate is not only a style requirement here. `system.query_log` is server-wide, so on a shared server the `query_id` alone is what separates this test's calibration query from every other database's rows; scoping it to `currentDatabase` is the same isolation the file's four other system-table reads already use. Measured on a debug build (Build ID `0a17b25bb964b5188c4ad76aa89bfa3c102b200d`, server `buildId` asserted equal to `readelf` before every arm): - the predicate is behaviour-preserving for the row the test wants: reading from the fixture's own database gives 60/69/60 ms with and without it; - it is load-bearing rather than decorative: with the same `query_id` read from a different database it returns 0 instead of 65, so it really does discriminate; - `various_checks.sh` is clean with the predicate and reports this file again when the two added lines are reverted. The test's own `read cost measured: 1` reference line is what pins this: a predicate that failed to match would print 0 and fail the test rather than silently falling back to the uncalibrated budget floor. It passes under both analyzers - 164 s with the new one and 182 s with `allow_experimental_analyzer=0` installed from `tests/config/users.d/analyzer.xml`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
CI finish ledger - 64d292bEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Two notes on the first row, both measured rather than assumed:
The Neither failure is caused by this PR's diff. Session id: cron:our-pr-ci-monitor:20260805-193000 |
Master took `04675` for `04675_kql_user_defined_functions`, so the pair moves to `05274` (free on master and in the open fleet worktrees). Master also added a `user_id_` parameter to the `QueryStatus` constructor, which the gtest fixture now passes as `std::nullopt` like the other gtests do, and renamed `deserializeStructureGranulePrefix` to `deserializeChunkStructurePrefix`, which a gtest comment names. Drop the two test comments that justified the fixture by the old analyzer, which master removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`readGranulePrefix` declares a one-row Compact granule (`num_rows = 1`) but served an empty buffer for the shared-data copy-sizes stream, so `deserializeArraySizesPositionIndependent` read no size and left the slot it had resized for that row uninitialized. Master's per-chunk Compact read, brought in by the last master merge, computes each chunk's nested limit from the offsets of all rows the chunk declares, so it now reads that slot. MSan reports it at `SerializationObjectSharedData.cpp:1720` in the two cells whose prefix read completes, `CumulativeSubThresholdPrefixesObserveCancellation` and `PrefixReadNotCancelledCompletesNormally`. Serve that row's size, 0, so the fixture is a well-formed one-row granule with no shared-data entries. Test-only; no assertion changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`distinct_json_paths ClickHouse#7` (a Wide part with `advanced` shared data) became 34.5% slower on arm in the performance comparison, at three builds on three master bases. Locally, one such query reads 41,024 chunk structure prefixes holding 1.28 million path names, and the prefix checkpoint added two costs: - `check()` read the clock after every name, which for a short name is the most expensive step of the loop: the vDSO `clock_gettime` alone was 18.6% of a single-thread profile of the query on x86. - The constructor polled cancellation unconditionally, so every prefix took two `weak_ptr::lock` on the query context and the process-list element, control blocks that all reading threads share. With 12 threads that kept the query at 13-22 ms against 9 ms on the base even without the clock. `check` now takes the size of the work done since the previous call and reads the clock only once 4 KiB of it, or 256 calls, have accumulated. The calls after a 64 KiB read chunk, a type decode and the `Variant` canonicalization still read it every time. The constructor only starts the thread's throttle. A name that fits in one chunk is read whole, as `readStringBinary` does, instead of being value-initialized again from an empty string. Release build, the test's own DDL and queries with LZ4, range of three medians of 13 runs each, base / before / after, in ms: ClickHouse#7 wide advanced shared data, 12 threads: 9 / 14-20 / 9 ClickHouse#7 wide advanced shared data, 1 thread: 38-41 / 69-71 / 40-43 ClickHouse#6 compact advanced shared data, 12 threads: 18 / 20-22 / 18-19 #0 compact dynamic paths, 1 thread: 364-379 / 395-405 / 364-371 ClickHouse#3 wide map shared data (not on this path): flat in all three. Cancellation is still observed inside the loops: the 20 `ObjectSerialization` gtests pass, and never reading the clock for small work, dropping the per-call floor, restarting the throttle per prefix, or reading long names whole each fails 6, 4, 1 and 4 of them. Without the entry poll, `CumulativeSubThresholdPrefixesObserveCancellation` now pins the throttle's thread lifetime, so its comments are updated along with the others that described the entry poll. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: 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
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since the Wide reader started serving granules from the columns cache, a run that draws use_columns_cache, enable_reads_from_columns_cache and enable_writes_to_columns_cache all on (1 in 8 under the CI randomizer) fills the cache during the calibration scan. Every cancellation attempt after that is answered from the cache without reading the structure prefix, so none lands inside the reader and the in-reader guard line reads 0. Measured on the merged head: with the three settings forced on the test fails 5/5 with exactly the CI diff, with use_columns_cache=0 it passes 5/5. The clamp keeps every other setting randomized. With it, 10/10 runs pass with cache reads and writes forced on and 12/12 under plain randomization. With the clamp line made unparseable, use_columns_cache=1 comes back in 5/10 runs and exactly those 5 fail. The Compact reader does not serve from the columns cache, so the compact test needs no clamp (3/3 with the cache forced on). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since f4572f6 (Validate the structure prefixes of JSON and Dynamic columns in Native format), deserializeObjectStructureStatePrefix rejects a dynamic-path list that repeats a path, with LOGICAL_ERROR on the part path. The not-cancelled control read 100000 empty, i.e. repeated, names to completion, so after the master merge it hit that error. In a debug or sanitizer build that aborts unit_tests_dbms, which is why all three Unit tests jobs on 3535ccb reported no test results at all. The empty-name cancellation cell stays: the reader consumes the whole list before it checks for repeats, so a cancellation still lands inside the loop. That fixture just no longer has a complete-read counterpart. ObjectSerialization.*: before, it aborts in PrefixReadNotCancelledCompletesNormally (Logical error: 'Duplicate path in the list of dynamic paths of an Object column'). After, 20/20 pass, three times. Full unit_tests_dbms (debug): 29711 tests, 0 failures. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since 9e118a6 (Cancel vector similarity index builds when a merge or mutation is cancelled), MergeTask and MutateTask install cancellation predicates on their thread group that throw ABORTED. A thread attached to that group afterwards copies them, and CurrentThread::checkIfNotCancelled invokes them, so the checkpoint is no longer inert for a merge or mutation. Comment only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 968b471Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
All 163 check runs completed and Session id: cron:our-pr-ci-monitor:20261011-030008 |
…-prefix-read-cancellation
CI finish ledger - 0c8cebaEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The same shard's Session id: cron:our-pr-ci-monitor:20261011-080006 |
…-prefix-read-cancellation # Conflicts: # src/Storages/MergeTree/checkDataPart.cpp
Since the columns cache serves Compact parts (ClickHouse#127287, 2c9139d), the Compact reader returns a cached granule without reading the JSON structure prefix, the same way the Wide reader already did. Once the calibration scan has filled the cache, the cancelled scans can no longer land inside the prefix read, so "cancelled inside the reader at least once" reads 0. Measured on the merged head (debug, Build ID 052cbf4d): - use_columns_cache=1 with reads and writes on: 5/5 FAIL with that diff; use_columns_cache=0 with reads and writes on: 3/3 OK. - with the clamp, randomized, reads and writes forced on: 10/10 OK, and query_log shows use_columns_cache never set in any run. - negative control (clamp line made unparseable): use_columns_cache=1 in 5/10 runs and exactly those 5 FAIL. - compact + wide, randomized, 25 runs each, 4 jobs: 50/50 OK. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hecker A call made without `processed_bytes` (one 64 KiB chunk of a long name) counts as 4 KiB, and a name of up to 64 KiB read whole is accounted after it is read, so the clock is not read "at least every 4 KiB of work". State the accounting rule instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion` Only the three readers recognised `PrefixReadCancelledException`; every other broken-part verdict still took it for corruption. Reproduced on this PR's head with a Wide JSON part that has no `columns_substreams.txt` (written before that file existed), where the part check and part loading read the structure prefix through `getColumnSample`: - a `CHECK TABLE` hit by `max_execution_time` reached `checkPartImpl`, which logged "looks broken", detached the healthy part and queued a fetch: on a single replica the table went from 5 rows to 0 on the second attempt; - a timed-out `ATTACH TABLE` made `loadDataPart` detach it as `broken-on-start` (ReplicatedMergeTree on the first attempt, MergeTree on the 20th); - a timed-out `RESTORE` reported the backup as damaged (`BACKUP_DAMAGED` in 12 of 15 attempts). Master cannot interrupt that read, so none of this happens there (60 timed-out checks, 2x40 attaches and 14 restores: 0 detached, 0 damaged). Every one of those verdicts, and the projection and detached-part attach paths, already skip anything `isRetryableException` accepts, which is how a merge's `ABORTED` is kept from marking parts broken. The exception is now accepted there, and the readers' separate test is dropped. Two callers still treat it apart from other retryable errors: `checkDataPart` propagates it instead of returning empty checksums, which would certify an unchecked part (one helper now serves both of its catches), and the part loading and restore retry loops give up at once, since the query stays cancelled (measured: 0 retries instead of 22 per 14 restores). The integration test cancels a `CHECK TABLE` inside that read (the `check_table_query_delay_for_part` delay outlasts the timeout) and requires the part to stay attached: it fails on the previous head (1 detached part, "looks broken"), passes here 4/4, and fails if the propagation in `checkDataPart`'s helper is removed (every check certified). The gtest now asserts the classification through `isRetryableException` and fails without the new branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Moving the retryable-error logging into `should_return_empty_checksums` left the outer `catch (...)` without any of the calls the `catch_all` style leg accepts, so it was reported as a silent swallow. It is not one: the helpers rethrow the exception, return empty checksums for a retryable error, or check the part again without the cache. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `max_execution_time = 0.001` the executor's own time-limit check at `PipelineExecutor::execute` fired before the part check began on sanitizer builds (elapsed 1.05-2.06 ms), so no check was ever interrupted and the liveness guard failed with (0, 0) in `Integration tests (amd_asan_ubsan, flaky)`, 2 of 2 workers, 10 of 10 attempts. A 100 ms timeout lets the check start on any build. The failpoint sleeps a random 0-999 ms before the part check, so the query is usually cancelled during the sleep and the check is interrupted at the structure prefix read; a shorter sleep lets the check finish or the query succeed, which the loop now accepts. 10 attempts keep the chance of no interrupted check negligible. Measured with the CI ASan binary of dc1bb4d: old test 2/2 FAIL (0, 0); new test 10/10 PASS (100 checks started, 98 interrupted, 2 verdicts), plus two concurrent full-module runs 12/12 each. Debug build 8e87230949df: 5/5 (50 started, 1 verdict). Pre-fix binary 5bbb3274 (b0cee28): 3/3 FAIL, part detached as "looks broken" from PrefixReadCancellationChecker in getColumnSample. A probe with a 10 s timeout passes every attempt as a success and fails only the liveness guard (10, 10). Co-Authored-By: Claude Opus 5.5 <[email protected]>
`calculateColumnsSizesOnDisk` passed the cached `total_columns_size` straight to `calculateEachColumnSizes`, which adds every column into it as it goes. For a Wide part without `columns_substreams.txt`, the size of a JSON column is computed by reading its structure prefix, which now observes query cancellation. A cancelled read of `system.parts` therefore left the columns before the JSON one in the cached total while the sizes stayed uncalculated, and the next calculation added them again: the inflated `data_compressed_bytes` / `data_uncompressed_bytes` / `marks_bytes` (also used for merge size estimates) then stayed for the lifetime of the part. Sum into a local and assign it with the per-column map. Behaviour on a successful calculation is unchanged: no caller relies on the member being added to. Reported by the AI review on ClickHouse#112918 (discussion r4371590325). Measured on the pre-fix CI ASan binary: three cancelled reads leave the total 3x the first column's size above the sum of the per-column sizes; the new integration test fails there 3/3 and passes on the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - a622382Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261025-213003 |
…andons The test failpoint `prepared_sets_build_ordered_set_inplace_fail` simulates an abandoned speculative in-place set build: `CreatingSetsTransform::generate` skips `Set::finishInsert`, but it then called `finishSubquery`, whose debug log reads `Set::getTotalRowCount` of the set it had just decided not to create. Since the external `IN` set can spill while it is built, `spillWhileBuilding` moves the keys into the disk set builder and resets `data`, and only `finishInsert` turns the builder into `disk_set`. An unfinished spilled set therefore has neither, and `getTotalRowCount` hits `chassert(data)` (a null dereference in a release build). The log arguments are evaluated only at debug level, which the CI server uses. AST fuzzer (amd_debug) hit it on PR ClickHouse#112918 (STID 2508-39cf) replaying 04489 with `max_bytes_before_external_set = 1`. A real early stop of the in-place pipeline (a subquery timeout with `overflow_mode = 'break'`, a cancel) never reaches `generate`, so the failpoint now returns without calling `finishSubquery`, like a real abandoned build. The normal path is unchanged. 04489 gets an arm that abandons a spilled in-place build and checks that the deferred build still returns the right count and that both builds spilled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-prefix-read-cancellation Conflicts in SerializationDynamic.cpp and SerializationObject.cpp: master (21a7d42) reads the four Native-reachable structure-prefix names (variant type names, flattened type names, dynamic paths, flattened paths) with `readStringBinaryGrowing`, so a declared length is never allocated before its bytes arrive, while this branch read the same lines with `readStringBinaryCancellable`, which reserves the declared length. Keep both properties: the four lines now call a new `readStringBinaryGrowingCancellable`, which grows the string as `readStringBinaryGrowing` does (same errors, ATTEMPT_TO_READ_AFTER_EOF on a short stream, as 05480 expects) and polls the cancellation checker between chunks of at most 64 KiB. The MergeTree-only reads (statistics entries, shared-data paths) stay on `readStringBinaryCancellable`, as master keeps them on `readStringBinary`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #110100
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Makes
KILL QUERYandmax_execution_timetake effect while a query is reading the structure prefix of aJSON/Objectcolumn. Previously such a read ran to completion no matter how long it took, so a killed query kept running and the time limit could be overshot by an order of magnitude.Description
SerializationObject::deserializeObjectStructureStatePrefixconsumes the whole path list, whose length and path sizes come from the stream, before the first row.ExecutionThreadContext::executeJobobserves cancellation only betweenworkcalls, and the prefix read had no checkpoint.The visible effect on a
Stress test (amd_asan_ubsan)hung check was aSELECTwithis_cancelled = 1still running after 594 s under a 60 smax_execution_time, making progress: a missing interruption point, not a hang. On a debug build,KILL QUERYlatency on a 600 MB path list drops from 2.088 s to 0.129 s.This adds a checkpoint inside the prefix loops, throttled on elapsed time (10 ms) and reading the clock once per 4 KiB of names, which kept
distinct_json_pathsat its base timing in a local A/B. A long name is read, and its string value-initialized, in 64 KiB chunks with a checkpoint between them; the work done with each name after it is read (hashing, matching or copying it, including theFLATTENEDduplicate check) is not polled. Because a cancellation can now surface inside a part read,isRetryableExceptiontreats it as transient, so no broken-part verdict (readers,CHECK TABLE, part loading,RESTORE) takes it for corruption: a cancelled check fails instead of passing or detaching the part. A part's lazily calculated column-size total is cached only when complete, so a cancelledsystem.partsread cannot double-count.The same checkpoint covers the per-chunk shared-data path list, and the
Dynamicstructure prefix between type descriptions and after theVariantcanonicalization, not inside either.The collector of the parallel dynamic-path prefix tasks surfaces a cancellation only when it is the only failure, so it cannot hide another task's read failure and leave a corrupt part unchecked.
Scope: the default
throwmode, nottimeout_overflow_mode = 'break'or client disconnect, neither of which setsis_killed.Workflow [PR]
Sync PR [sync-upstream/pr/112918]