Repository navigation
Conversation
`Storage memory check` reds green PRs. On ClickHouse#113201 at 996e0be, a PromQL-lexer-only diff that cannot touch MergeTree, `05_multiple_tables.sql` reported master=+183,456, PR=+250,512, change=+67,056 bytes (36.6%): https://github.com/ClickHouse/ClickHouse/actions/runs/35584353906/job/106535103120 `04_add_projection.sql` ends with MATERIALIZE PROJECTION ... SETTINGS mutations_sync = 2. StorageMergeTree::waitForMutation returns when the mutation is applied, signalled from inside the task's own step; the task object itself is destroyed later, on the executor thread, in MergeTreeBackgroundExecutor::routine's release_task. The profiler measured immediately after each scenario file, so a task still alive at the after_04 dump inflated that delta by +X and its release deflated after_05 by the same -X. The job only fails on a positive change (ci/jobs/storage_memory_check.py), so the cancelling half was always silently OK, and whichever arm lost the race decided which scenario turned red. Measured from the production report for 996e0be: 04 = -67,120, 05 = +67,056, sum -64, with every large 04 row the same stack negated in 05 (two Settings copies at 16,648 bytes each, ThreadGroup::ThreadGroup, MutateTask, MutationsInterpreter): 60,960 of 67,056 bytes, 90.9%. Over the last 1,440 CI runs with data, 8 of 68 scenario FAILs have that shape, 7 at 04/05 and one at 01/02. The profiler now waits for all four background executors to report zero outstanding tasks before every heap dump. Zero implies the memory is already freed: the metric is incremented in TaskRuntimeData's constructor at schedule time and decremented in its destructor, after resetTask() has destroyed the task, so it also covers pending tasks that never started. src/Storages/MergeTree/tests/gtest_executor.cpp already asserts this metric is zero as a quiescence predicate. The wait is bounded at 30 seconds and then throws TIMEOUT_EXCEEDED, so a genuine leak or hang fails the job loudly instead of being measured; the normal case costs no measurable time (96 s against 97 s for the whole sequence). Excluding the mutation stacks instead would blind the check to real regressions in mutation code, which is what it exists to catch. It is also unnecessary: once the transient task is gone, the genuine content of these two scenarios is +192 and +1,008 bytes, both below STORAGE_CHANGE_THRESHOLD_BYTES, so no threshold and no exclusion list needs widening. Validated locally by driving the job's own comparison code (analyze_heap_profiles, compute_cross_version_diff and the significance rule) over two heap-profile sets, with a local-only patch that delays release_task to widen the race deterministically. Unfixed, with the delay on the master arm only, scenario 05 FAILs and 236 cross-diff rows are master-arm-only releases summing 194,752 bytes, of which 120,816 are the mutation-task stacks. Fixed, same forcing: 2 rows and 544 bytes, and zero from the mutation stacks. Same-binary timeout A/B: a 40 s delay exits 1 with "Background tasks did not finish in 30 seconds" at the after_03 checkpoint, a 300 ms delay exits 0 over all nine, and the unfixed binary under the same 40 s delay exits 0, so the error comes from the drain observing a live task and not from the scaffold. A 5 s delay costs the fixed binary 107 s against the unfixed binary's 98 s, reproduced twice, so the wait is real. The master arm binary comes from the merge base, so this takes effect on both arms only once it is on master. Requested by @ alexey-milovidov on ClickHouse#113201 (comment) Related: ClickHouse#121364, which fixes a different arm of the same job.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings; bounded: 1 full pass +
Severity: ❌ blocker / Declared limits, so they are read as limits and not as claims:
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260922-050300 |
|
Workflow [PR], commit [a319420] Summary: ❌
AI ReviewSummaryThe PR fences all four background executors during storage heap checkpoints and transfers task ownership through Findings
💡 Nits
Missing context / blind spots
Final VerdictStatus: Make the checkpoint test release its blocked workers and preserve synchronization-object lifetimes on exception paths. |
Build profile diff (arm_release)Comparing commit See the job log for details. |
CI finish ledger - 3d3569dEvery 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
Neither row belongs to this diff, which touches only One caveat on the first row, so nobody tries to clear it by merging master. #121590 rewrites the previous release's Session id: cron:our-pr-ci-monitor:20260923-010313 |
ThinLTO inlining and identical-code folding can attribute equal live allocations to different container or column specializations. Anchor cross-build stacks at the stable ClickHouse caller so the differential flamegraph does not show balanced allocation plumbing as regressions and improvements. Observed in https://s3.amazonaws.com/clickhouse-test-reports/PRs/121083/30a51e18fa3534743e68311fb456773acefb760d/pr/storage_memory_check/storage_memory_report.html Related: ClickHouse#121083 Related: ClickHouse#121545
Preserve the executor-refusal retry behavior while retaining the scheduling ownership transfer. CI: https://github.com/ClickHouse/ClickHouse/actions/runs/42381391255/job/128447048074
| ASSERT_TRUE(executor->trySchedule(std::make_shared<BlockingExecutableTask>(task_started, finish_task, task_destroyed))); | ||
| task_started.wait(); | ||
|
|
||
| auto pause = std::async( |
There was a problem hiding this comment.
[Major] Unblock the test workers on exception paths
The task accepted at line 267 is already waiting on finish_task when this std::async starts. If creating the async thread throws std::system_error (for example, thread exhaustion), the countdown at line 289 is skipped. Unwinding then destroys the latches before executor, whose destructor joins the worker still waiting on finish_task. This can hang the entire unit-test process and leaves the worker referring to destroyed synchronization objects. There is another blocking unwind if the allocation at line 293 throws: destroying the async future joins its worker before anything releases release_pause.
Declare the latches before the executor and add cleanup that releases each outstanding wait before its corresponding future/executor joins, including when async creation itself fails. Moving the declarations alone does not unblock the workers.
The
Storage memory checkcould attribute a finished mutation task to either side of a heap-profile checkpoint.mutations_sync = 2waits until the mutation is applied, but the background executor can retain and destroy its task later. This produced equal-and-opposite allocation changes in adjacent scenarios and failed otherwise unrelated pull requests.Before each checkpoint, the profiler now pauses scheduling on all four
MergeTreeBackgroundExecutorinstances, waits for every already accepted task and foreground task-slot reservation to be released, and keeps scheduling paused through the jemalloc refresh and heap dump. The wait uses the executor's condition variable and a 30-second deadline: there is no polling or sleep, and a new task cannot enter after the idle observation.Task scheduling transfers the producer's reference through
BackgroundJobsAssigneeinto the executor before accepted work can run. This makes an idle executor imply that the task objects accepted through an assignee have also been destroyed, rather than merely that the executor released its own references.Deterministic executor tests verify that the checkpoint wait includes task destruction, that
tryScheduleremains blocked until the checkpoint guard is released, and that a scheduling caller held after enqueue no longer retains the completed task.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
Storage memory checknow takes heap-profile checkpoints only after background executor work is destroyed and while new scheduling is fenced.Workflow [PR]
Sync PR [sync-upstream/pr/121545]