Skip to content

Do not log the size of a set that the in-place set-build failpoint abandons - #127786

Merged
PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-inplace-set-failpoint-spilled-set
Nov 2, 2026
Merged

PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-inplace-set-failpoint-spilled-set

Conversation

@groeneai

@groeneai groeneai commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #112918

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

AST fuzzer (amd_debug) aborted with Logical error: 'data' (STID 2508-39cf) while replaying 04489_not_ready_set_inplace_build in a session with max_bytes_before_external_set = 1.

The test failpoint prepared_sets_build_ordered_set_inplace_fail simulates an abandoned in-place set build: CreatingSetsTransform::generate skips Set::finishInsert, but it still called finishSubquery, whose debug log reads Set::getTotalRowCount. An external IN set can spill while it is built, and such a set, if never finished, has neither its keys in memory (spillWhileBuilding resets them) nor a disk set (only finishInsert creates it), so getTotalRowCount hits chassert(data). A real early stop never reaches generate, so only the failpoint is affected.

The failpoint now returns without calling finishSubquery, the way a real abandoned build stops. No production path changes.

04489_not_ready_set_inplace_build 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 (SetsSpilledToDisk grows by at least 2).

Validation: on the unfixed debug build the arm aborts the server with the CI stack (Set::getTotalRowCount <- CreatingSetsTransform::finishSubquery). With the fix it passes 50/50 randomized runs, each with exactly 2 spills. Without max_bytes_before_external_set = 1 the spill check fails, so the arm cannot pass vacuously.

🤖 Generated with Claude Code


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

Version info

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

…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]>
@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; 0 findings) plus my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 The new 04489 arm's comment describes the check as "the deferred build must still create the set", while the defect was reading the size of the abandoned, spilled set AGREE, not blocking The assertions are right: 400 shows the server survives the abandoned spilled build (the unfixed server dies on this arm), and the SetsSpilledToDisk delta of at least 2 shows both builds spilled

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261025-173000

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. clickhouse local --logger.console=1 --log-level=trace with the failpoint enabled and SETTINGS max_bytes_before_external_set = 1 on a 1000-row UInt64 MergeTree aborts on every run on the unfixed debug build, with the CI signature. The new 04489 arm aborts an unfixed server the same way.
b Root cause explained? Set::spillWhileBuilding resets the in-memory keys and only Set::finishInsert creates the disk set. The failpoint skips finishInsert but still called finishSubquery, whose debug log reads getTotalRowCount of a spilled, unfinished set, which has neither, so chassert(data) fires. The log arguments are evaluated only at debug level, which CI's server uses.
c Fix matches root cause? Yes. The failpoint now stops like a real abandoned build, which never reaches generate. No guard in Set, no change to the normal path.
d Test intent preserved / new tests added? Yes. 04489_not_ready_set_inplace_build extended additions-only: the arm checks the deferred build's count and that both builds spilled, so it fails if the arm stops spilling.
e Both directions demonstrated? Yes. Unfixed server: the arm aborts it (server died). Fixed: passes, 50/50 randomized runs, every run with SetsSpilledToDisk = 2. Without max_bytes_before_external_set = 1 the last line becomes 0.
f Fix is general across code paths? Yes. finishSubquery is called only from generate, and the normal call runs after finishInsert. The other readers of getTotalRowCount require a created set, and tuple and runtime-filter sets never get spill settings.
g Fix generalizes across inputs (params/datatypes/wrappers)? The removed call does not depend on the key type, data or settings; 50 randomized runs gave the same result.
h Backward compatible? (maintainer-approved exception only) Yes. Only the failpoint body changes: no setting, format or user-visible change.
i Invariants and contracts preserved? Yes. getTotalRowCount is now read only on a finished set. The failpoint's contract is unchanged: the set is not created, the unfulfilled promise publishes no set, and the deferred build recovers it.

Session id: cron:clickhouse-impl-slot-4:20261025-170700

@clickhouse-gh

clickhouse-gh Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [70061b4]

Summary: ❌

job_name test_name status info comment
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb IGNORED

AI Review

Summary

PR #127786 prevents the in-place set-build failpoint from logging the size of an unfinished spilled Set and adds regression coverage for the deferred rebuild. Reviewed the current code, diff, and all prior discussion; no actionable findings.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov @nihalzp, could you review this and add the can be tested label so CI runs? The prepared_sets_build_ordered_set_inplace_fail failpoint skipped Set::finishInsert but still called finishSubquery, whose debug log reads getTotalRowCount of a set that may have spilled while it was built, so chassert(data) fired under max_bytes_before_external_set = 1; the failpoint now returns without finishSubquery, and 04489 gets a spilled arm.

@clickhouse-gh clickhouse-gh Bot added the comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. label Oct 25, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 1948228

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 profile diff infra, not from this PR: the CI logs cluster never passed the readiness probe, so the job ended with LogClusterNotReady: the endpoint never became ready before comparing anything. 282 of 286 runs since 2026-10-26 22:00 UTC are red, on 236 PRs #126200 (mine, open)
PR praktika rollup of the row above #126200 (the owner of the row above)

The first run of this head stopped at Config Workflow / Pre Hooks because the can be tested label was not set yet; the run after the label was added is the one above. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261027-203012

@PedroTadim PedroTadim self-assigned this Oct 30, 2026
@PedroTadim
PedroTadim enabled auto-merge October 30, 2026 11:17
@clickhouse-gh

clickhouse-gh Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 70061b42b with master 0fa0b74d0 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 509fb3681; 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.

Compile time of recompiled translation units

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

Job report

@PedroTadim
PedroTadim added this pull request to the merge queue Nov 2, 2026
Merged via the queue into ClickHouse:master with commit d6c89bc Nov 2, 2026
177 of 179 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 2, 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-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-ci 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.

4 participants