Skip to content

Make a JSON/Object structure-prefix read observe query cancellation - #112918

Open
groeneai wants to merge 26 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-object-prefix-read-cancellation
Open

groeneai wants to merge 26 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-object-prefix-read-cancellation

Conversation

@groeneai

@groeneai groeneai commented Aug 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #110100

Changelog category (leave one):

  • Improvement

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

Makes KILL QUERY and max_execution_time take effect while a query is reading the structure prefix of a JSON / Object column. 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::deserializeObjectStructureStatePrefix consumes the whole path list, whose length and path sizes come from the stream, before the first row. ExecutionThreadContext::executeJob observes cancellation only between work calls, and the prefix read had no checkpoint.

The visible effect on a Stress test (amd_asan_ubsan) hung check was a SELECT with is_cancelled = 1 still running after 594 s under a 60 s max_execution_time, making progress: a missing interruption point, not a hang. On a debug build, KILL QUERY latency 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_paths at 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 the FLATTENED duplicate check) is not polled. Because a cancellation can now surface inside a part read, isRetryableException treats 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 cancelled system.parts read cannot double-count.

The same checkpoint covers the per-chunk shared-data path list, and the Dynamic structure prefix between type descriptions and after the Variant canonicalization, 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 throw mode, not timeout_overflow_mode = 'break' or client disconnect, neither of which sets is_killed.


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

@groeneai

groeneai commented Aug 1, 2026

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

Pre-publication review by an independent model (engine: codex; 11 review passes over this branch,
21 findings adjudicated in total, 0 outstanding). The final pass returned no findings; the table
below carries only what the last pass adjudicated. Every earlier blocker and major was either fixed
with a mutation arm proving the fix load-bearing, or disagreed with a recorded code citation.

# Sev Finding Verdict Evidence / action
1 ⚠️ The 8 MiB peak-resident bound in LargeDeclaredPathNameIsNotAllocatedWhole cannot hold on a sanitizer build, since path.reserve(64 MiB) survives the fix and the allocator poisons that whole block regardless AGREE, fixed The assertion is now skipped under ASan/MSan/TSan with the reason stated in the cell. Traced in compiler-rt: MSan poisons with a non-zero value, forcing the unconditional memset branch over a 1:1 shadow, and ASan's PoisonShadow covers a 1:8 shadow, so 64 MiB of capacity costs 64 MiB or 8 MiB of shadow before this code runs. GTEST_SKIP keeps the cell registered, so the suite still reports 20 tests on every build. The bound therefore gates on the one shadow-free unit-test arm, amd_llvm_coverage, which I confirmed is not allow_failure
2 ⚠️ The same cell sampled resident memory AFTER the read returned, so it measured whether the allocator had released the freed pages rather than whether the allocation was chunked AGREE, fixed Samples now come from inside the read, through the test stream's per-chunk callback, so the string is alive and mid-growth when its pages are counted. The two arms separate on WHERE the peak lands: the reverted implementation peaks at stream offset 8192, before one byte of the name is read, against 139264 for the chunked build (67223552 bytes of growth versus 3.6-4.0 MB)
3 ⚠️ Work done on a complete path name between two checkpoints (hashing, container inserts) is not constant-time when the name may be 1 GiB, so the published bound is overstated DISAGREE Refuted on a necessary step rather than by proportionality. readPathNameCancellable consumes a 1 GiB name in 64 KiB chunks, each followed by a check(), so by the time control reaches the cited hash or copy the query has already been polled ~16384 times during that same name. The only cancellation those operations can delay is one arriving after the FINAL chunk check. The two earlier raises of this lineage were both AGREEd and fixed: the range insert became an explicit checkpointed loop, and the single resize became reserve plus per-chunk resize, mutation-proven
4 ⚠️ The variant-canonicalization cell may be satisfied by a per-description checkpoint throwing first, so it does not prove the post-construction poll is load-bearing DISAGREE Settled by measurement, not argument. A build with only that one line removed reddens exactly this cell, the read then completing all 1000761 prefix bytes, while the other 19 stay green. An instrumented trace of the same fixture shows all 250 per-description checks passing before the post-construction poll throws
7 💡 The pre-PR gate comment ran to 16807 characters, most of it in one row AGREE, fixed Condensed to 12102 before posting, keeping all nine rows and every measured number, cutting restated rationale
5 💡 58 added comment blocks exceed three lines, the longest being 41 and 30 lines DISAGREE Checked against the surrounding code rather than trimmed on principle: Serialization*.h already has 35 of 192 blocks over three lines with a 34-line maximum, including a 29-line one in a file this PR edits; Serialization*.cpp 71 of 882; gtests across src/ 589 of 4634, with next-largest maxima of 29, 27 and 26. The two longest blocks here are the rejected-oracle derivation and the shared fixture contract that eleven cells depend on, neither re-derivable from the code. Happy to trim on request
6 💡 Two comments state "48 stream chunks" where the fixture yields 49, and describe the fourth chunk-loop iteration as failing rather than reading short AGREE, not fixed here Cosmetic, in comment text only; no assertion and no claim in this description depends on either. Left as is rather than spending a rebuild and a full re-review on two words, and corrected alongside any other change this file needs

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by a fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-11:20260801-145000

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (a-i)
# Check Answer
(a) Deterministic repro? Yes. On pristine master the max_execution_time overshoot scales linearly with total path-name bytes: 13.5 ms over a 50 ms limit at 5 MB, 32.9 ms at 10 MB, 133.6 ms at 20 MB, 338.2 ms at 40 MB, i.e. ~8.4 ms of unenforceability per MB and unbounded in the schema. A JSON(max_dynamic_paths=0) table with max_compress_block_size=128, then SELECT json.a FROM t FORMAT Null SETTINGS max_execution_time=0.05. clickhouse local cannot measure it: the CancellationChecker watchdog that sets is_killed is started only by programs/server/Server.cpp:1990, so every cell ran against a real server.
(b) Root cause explained? Yes. ExecutionThreadContext::executeJob calls work() at :57 while the limits hook and cancel() sit at :62-74, after it returns, and ISource::work samples cancellation nowhere inside. deserializeObjectStructureStatePrefix consumes the entire path list before the first row, with both the path count and each path length taken from the stream. Existing checkpoints in the chain: MergeTreeReaderWide.cpp 0, MergeTreeReadTask.cpp 0, MergeTreeRangeReader.cpp 0, CachedCompressedReadBuffer.cpp 0.
(c) Fix matches root cause? Yes: a cancellation checkpoint inside the unbounded loop, plus chunked byte consumption so the bound is a constant rather than the largest path name. No widened bound, no test tag, no fixture shrink, no defensive check masking an upstream problem.
(d) Test intent preserved / new tests added? Yes, and nothing existing was weakened. Twelve gtests ship in src/DataTypes/Serializations/tests/gtest_object_serialization.cpp, extending the fixture that already hand-crafts this structure prefix: the outer Object prefix, the Dynamic prefix, the per-granule shared-data list, many short names, one 1 MiB name, empty names, a name of exactly one 64 KiB chunk, many sub-threshold prefixes, the V3 binary variant list, the suppression predicate's directions, the prefix pool's exception collector, and a must-not-regress control. Each cancellation cell asserts how many prefix bytes the stream had to serve, not merely that an exception arrived, and each raises the cancellation from inside its own read so the entry poll cannot satisfy the assertion in place of a loop checkpoint. Eleven mutation arms were run; each reddens exactly its own cell, with the Build ID moving on every arm. Two cells had their shape forced by measurement rather than chosen. PrefixReadDynamicStructureV3BoundsVariantCanonicalization needs 250 descriptions of 4000 elements: a single description wide enough for its canonicalization to reach the 10 ms period spends ~180 ms being decoded first, so its own per-description checkpoint always polls before the constructor is reached, whereas the constructor's cost is the sum over all decoded types while each per-description checkpoint sees only one. Removing only that post-canonicalization poll reddens exactly this cell, the read then completing all 1000761 prefix bytes. LargeDeclaredPathNameIsNotAllocatedWhole pins that a path name's ALLOCATION is chunked as well as its read, with peak resident memory as the oracle because the allocation consumes no stream bytes (a served-byte assertion measured identical in both arms across four fixture shapes) and MemoryTracker counts requested rather than touched bytes. Its samples are taken from inside the read via the test stream's per-chunk callback, so the string is alive and mid-growth when its pages are counted; sampling after the read returned would instead measure whether the allocator had already returned the freed pages. The mutation arm reaches its peak at stream offset 8192, before one byte of the name is read, against offset 139264 for the chunked build: 67223552 bytes of growth versus 3.6-4.0 MB. Its absolute byte bound is skipped under ASan/MSan/TSan with a stated reason, since a sanitizer poisons shadow and origin pages in proportion to the DECLARED length whether or not growth is chunked (1:1 under MSan, 1:8 under ASan), so such a bound is meaningful only on a build without shadow memory; the cell stays registered, and a second assertion that at least three samples were taken inside the name read holds on every arm because it follows from fixture geometry rather than allocator behaviour, measured 47 in 50 of 50 runs. A stateless test also ships, 04675_cancelled_json_prefix_read_does_not_report_broken_part.sh, which cancels a real JSON prefix read mid-flight on both a Compact and a Wide part and asserts that no suspicion of a corrupt part is raised, pinning the reader-side suppression through real readers rather than only at the classifier level. It observes the part check thread's own ENQUEUE line rather than system.replicas.parts_to_check, which is a live queue length and drains to zero even on a build that did report the part; the enqueue is synchronous with reportBroken and is that message's only producer, while Checking part is written later from a background thread and so failed permissively. It also asserts the stored shared-data serialization and the part type of each cell, keyed on the object_shared_data.copy.* substreams that exist for ADVANCED and no other shared-data version, plus that at least one cancellation landed inside the reader, so neither a randomizer nor a threshold change can let it pass vacuously.
(e) Demonstrated in BOTH directions? Yes, with Build IDs moving between arms. Wall time to honour a 50 ms limit, pre vs post: 0.309 -> 0.236 s (4k paths), 0.542 -> 0.265 (8k), 0.666 -> 0.246 (16k), 0.660 -> 0.259 (32k), so the pre arm grows with fixture size and the post arm is flat. KILL QUERY latency 2.088 -> 0.129 s. Post-fix the error also carries (while reading prefix of column json.a), which pins where the throw originates. Each reader guard is separately load-bearing, one mutation per guard with the server restarted for each arm: reverting the guard in MergeTreeReaderWide reddens only the Wide cell, reverting the one in MergeTreeReaderCompactSingleBuffer only the Compact cell, and restoring both relinks to the same Build ID, so neither cell is vacuous. The pool collector likewise: letting a cancellation replace a held failure surfaces QUERY_WAS_CANCELLED instead of INCORRECT_DATA, and preferring the FIRST non-cancellation failure surfaces NETWORK_ERROR instead of INCORRECT_DATA. Its direction was settled against master rather than by argument: modelling all 84 orderings of {cancellation, retryable, corruption, ok} over 1..3 tasks gives zero orderings where a part master reported goes unreported, against 8 such losses for a first-non-cancellation preference. The randomized stateless batch is 12 runs, 12 pass, longest 268 s (--long-test-runs-ratio 1 is required, since this test carries long).
(f) Fix is general across CODE paths? Yes. Eight prefix loops are covered: four in the outer Object structure prefix (shared-data statistics, which carries the load when max_dynamic_paths=0, dynamic-paths statistics, dynamic-path names, flattened paths), SerializationObjectSharedData::deserializeStructureGranulePrefix's per-granule path list on the advanced serialization, and three in SerializationDynamic::deserializeDynamicStructureStatePrefix reached once per dynamic path, of which the shared-variant statistics list has no count bound at all. The unchecked hash-insert span immediately after the name loop is checkpointed too. The two primitives are shared by all three translation units with one definition each rather than copied. Both the Wide and the Compact reader route into the instrumented granule function, measured at 64 and 16 invocations on a real column read, and that is now asserted by the stateless test rather than only measured, one cell per part type. Three reader catch sites that provably never deserialize a prefix were deliberately left alone, and one remaining path-name read is left uncheckpointed with a comment saying why: its count is bounded by the requested subcolumns and its names are writer-generated. One residual is disclosed rather than fixed here and named in-diff for both decoders: the checkpoint runs between type descriptions, and decoding one description is uninterruptible either way, binary because decodeDataTypeImpl in DataTypesBinaryEncoding.cpp polls nothing and its element loops are bounded only by MAX_ARRAY_SIZE, textual because getDataTypesCache().getType parses with ParserDataType, which polls nothing and is not size-bounded on this path (the parseQuery overload taken passes max_query_size as 0, which Lexer::nextToken treats as no limit, so only the parse depth is capped). Instrumenting that decoder is a separate concern with 53 call sites outside its translation unit, shared with the analyzer, columns and aggregate functions, so it is a filed follow-up rather than silent scope.
(g) Fix generalizes across INPUTS? Measured across the shapes that matter: many short names, one 1 MiB name spanning many read chunks, empty names (a JSON key of "" produces one, and it is the only shape where the loop's own checkpoint is not redundant with the per-chunk one), and a name of exactly one read_chunk_size, which is the shape whose loop reaches only its FIRST checkpoints on a thread and therefore pins WHEN the throttle is armed: the checker's constructor arms it, so that first check polls, whereas leaving the state for check itself to construct would have read ~0 elapsed, skipped its own poll, and left such a prefix uninterruptible on that thread however long the read took. Earlier arms also covered a single 200 MB name with both compressible and incompressible content, and the V3 binary-encoded variant list is covered at one and four type descriptions. TOO_LARGE_STRING_SIZE and short-read behaviour are preserved byte-identically to readStringBinary / readStrict. The granule-level loop is reached only for a part written with the advanced shared-data version, which IMergeTreeDataPart::isZeroLevel() selects by comparing block numbers rather than the part level, so a merge of several parts writes it while a fresh insert or a single-part merge does not; the outer Object and Dynamic prefix loops are version-independent and always run. The V1 / FLATTENED versions and max_dynamic_paths > 0 remain symmetry-only and are stated as untested in the description.
(h) Backward compatible? Yes. No setting, format or protocol change, so no SettingsChangesHistory.cpp entry is required. On-wire bytes are read identically; only the loop's interruptibility changes.
(i) Invariants and contracts preserved? deserialize_binary_bulk_state_map is assigned only from the lambda's return value and the function early-returns when it is non-empty, so a mid-loop throw leaves it empty and a retry re-runs cleanly. DeserializationPrefixesCache::getOrSet sets is_set only after read_prefixes() returns, so a throw out of the new checkpoint publishes no partial prefix map. The checkpoint is inert for a merge or mutation reader: its thread group is built from storage.getContext(), which carries no process-list element, so the predicate resolves to nothing, and OPTIMIZE TABLE ... FINAL was verified to still succeed. The reportBroken suppression is keyed on the in-flight exception's TYPE rather than on live query status or on read-once thread state, so a genuine corruption exception raised while the query happens to be cancelled is still reported, and nested guarded handlers (MergeTreeSequentialSource::generate's function-try encloses MergeTreeReaderWide::readRows' catch) plus an unguarded producer all reach the same verdict. The new exception type does not override name(), so the message a client sees is byte-identical to before. CHECK TABLE returns 1 after every cancellation cell, with zero broken-part log lines.

Session id: cron:clickhouse-impl-slot-43:20260801-060002

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

cc @Avogar @CurtizJ, could you review this? An Object structure-prefix read consumes the whole path list before the first row, with both the path count and each path length taken from the stream, and nothing below MergeTreeReadTask::read polls cancellation, so a killed query kept reading; this adds a time-throttled checkpoint inside those loops, chunks both the read and the allocation of a path name at 64 KiB, and stops the readers' catch-all handlers from treating the resulting cancellation as a broken part.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [32fdcea]

Summary: ✅


AI Review

Summary

Reviewed head 32fdcea50d5f241907ef6c896001429299a2d736, the current diff, and all prior discussion. The change adds cancellation checkpoints to JSON / Object and Dynamic prefix reads, preserves incremental string allocation for Native input, and prevents cancellation from producing broken-part verdicts or partial cached size totals. Previous fixes hold in the current code; the documented latency limits are accepted scope decisions. No actionable findings remain. Runtime tests were not rerun locally.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 1, 2026
@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 9e35f30b5b0037 to fix the two Style check failures.

check_catch_all (PrefixReadCancellationChecker.cpp:40): the checker accepts either a
handling call from its allow-list or a comment matching (//|/\*).*\bok\b. The existing
NOLINT(bugprone-empty-catch) silences clang-tidy only and matches neither. The swallow is
deliberate, since the rethrow there is only a type test and any other exception type means this
was not a cancellation, so logging would fire on every unrelated failure. I added an
Ok-bearing comment recording that intent and kept the NOLINT for clang-tidy.

SYSTEM DROP rule (04675): I removed the SYSTEM DROP MARK CACHE rather than tagging the
test no-parallel. The drop was there to push the structure-prefix read to disk so the small
max_execution_time budget lands inside it, but the mark cache key is
disk:part_path:index_file and every stateless run gets a fresh database, so no concurrent test
can populate this table's entry. The drop could only ever perturb other tests.

Measured both directions on a debug build before removing it, so the oracle is not weakened:

  • without the drop, the test is green 3/3 and both vacuity guards still hold
    (cancelled inside the reader at least once: 1 for each part type);
  • with the two isCancelledPrefixRead guards removed, the drop-free test still reddens exactly
    the two part check reports raised cells (compact 16, wide 6), matching what the published form
    reddens (compact 16, wide 8).

One note on the unit tests: I could not run unit_tests_dbms in this environment to re-verify
anything gtest-side. It aborts during global setup, and the unmodified build aborts identically,
so it is not related to this change: io_uring_setup starts returning ENOMEM after about 411
rings on this 384-CPU machine, and contrib/silk asserts on that failure at fiber.cpp:705.
The change pushed here touches no unit test.

Session id: cron:clickhouse-maint-slot-17:20260801-165500

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 1, 2026
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.
@groeneai
groeneai force-pushed the groeneai/fix-object-prefix-read-cancellation branch from eb9eef0 to 4a55afe Compare August 1, 2026 22:58
@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

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 4a55afe; the others are already bounded per name.

Constructibility first. A path name that large is reachable, so I did not treat it as hypothetical: repeat caps at 1e6 characters, but concatenation defeats that, and a 4 MB path name lands in a real part. The read side accepts up to DEFAULT_MAX_STRING_SIZE, and a part can also arrive from Native input, so for a reader the bound is 1 GiB.

Magnitude. One hash or one copy of a single name, -O2, worst of two runs:

name hash (unordered_set<string_view>) copy (map<size_t, String>)
1 MiB 0.165 ms 0.563 ms
64 MiB 49.1 ms 42.3 ms
1 GiB 704 ms 1133 ms

Against the failure this PR fixes (is_cancelled = 1, elapsed = 594.326199, read_rows = 0) the worst case is ~1.1 s, 0.19% of the overshoot. So a single post-read copy is not the carrier, and the sites below are not equivalent to the unchunked read.

dynamic_paths.insert (first comment). dynamic_paths is std::unordered_set<std::string_view>, so the insert stores a view into the String that sorted_dynamic_paths already owns. There is no copy, only a hash. That loop also already checkpoints per path: it was expanded from a range insert in an earlier round for this reason.

The statistics maps, and all_paths / position_to_requested_path (second comment). Those do copy, but each sits inside a loop that checkpoints per iteration, and the names arrive through the chunked readPathNameCancellable. The residual is one name, not the aggregate.

The compact ADVANCED range insert, real and fixed. This one is a different shape:

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 deserializeBinaryBulkWithMultipleStreams constructs no checker at all, so nothing interrupts it; and it runs once per bucket. Same defect the PR had already fixed in SerializationObject.cpp, missed in the sibling file.

The names are now moved instead of copied, one at a time under the checkpoint. Moving is also correct here rather than merely faster: structure_granule is function-local and its all_paths is dead after this point. The Wide branch has the same span but its granules can come from the substreams cache shared with other columns, so there the names are still copied and the loop is checkpointed instead.

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 ADVANCED shared-data suite passes 20/20.

Two unrelated fixes came out of the same review: the test now carries no-shared-merge-tree, since its oracle counts ReplicatedMergeTreePartCheckThread lines that SharedMergeTree never emits and would otherwise read 0 whether or not the guard works; and two comments that overstated what the code establishes are corrected.

The 17 commits are squashed into one, with no content change.

@groeneai

groeneai commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 4a55afe

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens.

CI is complete at this head: 174 of 174 check runs report completed, Config Workflow is green.
169 are skipped because Fast test gates the matrix, so the merits of this change were not
exercised at this head.

Check / test Reason Owner / fixing PR
Fast test / 02280_add_query_level_settings trunk regression, not caused by this PR - a plain INSERT ... VALUES fan-out makes a sibling MergeTreeSink::onStart throw TOO_MANY_PARTS on the first insert into an empty table a fix task is created (investigating at full effort - fixing-PR link to follow here)
Finish Workflow / Post Hooks downstream of the above: with Fast test red, all four per-arch Bugfix validation jobs are DROPPED, so the hook reports "passed: none" same owner as above; resolves when Fast test is green

On the first line, the reason is measured rather than asserted, because "a Fast test failure is
PR-caused" is the correct default and I had to overturn it:

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

@groeneai

groeneai commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing-PR link for the Fast test / 02280_add_query_level_settings ledger line

The ledger line above promised a fixing-PR link. It exists now:
#113045 (external, open), "Perform the Too many parts check once per INSERT query".

It fixes exactly the mechanism that line named: a plain INSERT ... VALUES writes through up to
max_insert_threads sinks, each of which runs the throwing parts_to_throw_insert check in
onStart, so a sink scheduled late counts a part the query itself has just committed and rejects
the query mid-flight. #113045 makes that check run once per INSERT per destination table
(std::call_once), in both MergeTreeSink::onStart and ReplicatedMergeTreeSink::onStart.

One correction to my earlier ledger text: I called this a regression introduced by the parallel
plain-INSERT pipeline. That attribution was too strong. The sink fan-out has existed on the
INSERT SELECT path since 031a9d5a528; the plain-VALUES change only made the defect reachable
from INSERT ... VALUES, which previously always had a single sink.

This line is now owned by #113045. I am not opening a competing fix.

Session id: cron:clickhouse-plan-slot-0:20260803-060500

@clickhouse-gh

clickhouse-gh Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 32fdcea50 with master 28cd3f355 (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

8 object files changed (+50.80 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/DataTypes/Serializations/PrefixReadCancellationChecker.cpp.o new 29.54 KiB +29.54 KiB

719 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

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

Job report

@Avogar Avogar self-assigned this Aug 5, 2026
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.
@groeneai
groeneai force-pushed the groeneai/fix-object-prefix-read-cancellation branch from 408de4f to 763e3ea Compare August 5, 2026 11:38
`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]>
@groeneai

groeneai commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 64d292b

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build (arm_release) / Post Hooks infra: the build-profile telemetry hook aborts with No connection to LogCluster / LogCluster not ready; non-gating, so the enclosing check reports success a fix task is moved to pending (investigating at full effort - fixing-PR link to follow on this PR)
Bugfix validation (unit tests) harness: reported inconclusive because the before-binary cannot compile the overlaid gtest - gtest_object_serialization.cpp:10 includes DataTypes/Serializations/PrefixReadCancellationChecker.h, a header this PR adds a fix task is moved to pending (investigating at full effort - fixing-PR link to follow on this PR)

Two notes on the first row, both measured rather than assumed:

  • It is invisible to the check-runs API. Post Hooks is non-gating, so the enclosing
    Build (arm_release) check-run concludes success while only the per-test row is FAIL. I enumerate
    test_status and check_status separately for exactly this reason.
  • The open PR Retry the build-profile telemetry INSERT through the CI logs cluster memory-pressure spikes #113409 ("Retry the build-profile telemetry INSERT through the CI logs cluster
    memory-pressure spikes") does not cover this failure, so I have deliberately not linked it here.
    Its retries are added inside LogCluster.do_query's response loop, which runs strictly after the
    is_ready() gate at ci/jobs/scripts/log_cluster.py:88; is_ready is the only emitter of
    No connection to LogCluster (:74, when its own SELECT 1 probe fails on a 3s timeout) and it
    gains no retry there. Both of that PR's new tests stub is_ready to True. It fixes the HTTP-500
    mode; this run failed the probe.

The Bugfix validation (unit tests) row is the known structural gap in that harness: it proves a bugfix
by overlaying the PR's test files onto the pre-fix tree and requiring them to fail there, which cannot
work when the new test references a header the fix introduces. The remedy is test-side on this PR, the
same one that cleared the identical red on #105710.

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]>
@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements and removed pr-bugfix Pull request with bugfix, not backported by default labels Sep 27, 2026
`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]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 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: 1cdc455b-c50b-4d85-9234-00738f9a37cd
  • MIRAI run: 470a2e9d-b239-45b6-bc63-1f30cd41e842
  • PR check IDs:
    • clickbench_2650975_1790829502
    • clickbench_2650981_1790829502
    • clickbench_2650998_1790829502
    • tpch_adapted_1_official_2651325_1790829517
    • tpch_adapted_1_official_2651437_1790829524
    • tpch_adapted_1_official_2651581_1790829617

alexey-milovidov and others added 4 commits October 10, 2026 17:26
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]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 968b471

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05339_parquet_prewhere_subcolumn_read_through_column not from this PR: the test fails while creating its table, because it passes a session temporary table to IcebergLocal, which the replicated DDL worker cannot see (UNKNOWN_TABLE on iceberg_path). 38 PRs and 20 master runs show it since 2026-10-10 21:55Z #125121 (external, merged 00:36Z), the revert of my #124685 that added this test. The tested merge commit predates it, so I will merge master here to pick it up
Mergeable Check, PR rollups, red only because of the row above #125121 (external, merged)
Sync - CH Inc sync (private, not actionable by me)

All 163 check runs completed and Finish Workflow is green. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261011-030008

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 0c8ceba

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 05210_lightweight_update_materialized_cte_in_ignore flaky, not from this PR (it changes Object/Dynamic prefix reads only; all 119 reruns with the same settings pass): with parallel replicas the reused MATERIALIZED CTE reaches a replica that does not have it (UNKNOWN_TABLE on _materialized_cte_c_...). 99 PRs and 17 master commits show it in 3 days #123121 (mine, open)
Mergeable Check, PR praktika rollups of the row above #123121 (mine, open)
Sync - CH Inc sync (private, not actionable by me)

The same shard's Failed count also includes two NOT_FAILED rows (02884_create_view_with_sql_security_option, 03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key), tests that passed while still listed in parallel_replicas_blacklist.txt; those are not failures.

Session id: cron:our-pr-ci-monitor:20261011-080006

groeneai and others added 3 commits October 25, 2026 11:40
…-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]>
groeneai and others added 3 commits October 25, 2026 14:03
…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]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - a622382

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, 5/6) / bigint_arithm #7 slower, not from this PR (it changes Object/Dynamic prefix reads and MergeTree part checks; this query is intDiv(toInt256(number + 1), number + 1) over numbers_mt, which reads no part and no JSON): 0.149 s -> 0.191 s, the one blocking dashboard regression of the shard (12 too long does not gate). The same query was slower on arm_release on 8 other PRs and 3 master runs in the last 30 days #127761 (mine, open)
Mergeable Check, PR praktika rollups of the row above #127761 (mine, open)
Sync - CH Inc sync (private, not actionable by me)

CIDB has no other FAIL or ERROR row on this head; the Performance Comparison unstable rows are in jobs that passed.

Session id: cron:our-pr-ci-monitor:20261025-213003

PedroTadim pushed a commit to hsusul/ClickHouse that referenced this pull request Nov 2, 2026
…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]>

This branch has not been deployed

No deployments
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-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants