Repository navigation
Backport #108391 to 26.6: Fix data race on MemoryReservation release at query finish - #112885
Conversation
…e at query finish `BlockIO::onFinish` released the whole set of workload resources — including the `MemoryReservation` — before the query pipeline was finalized, while pipeline threads still hold raw pointers to it through `WorkloadResources` in `PipelineExecutor`. Split the release: the query slot is released early (safe, pipeline threads never touch it), the memory reservation only after the pipeline has been finalized and its threads joined. `BlockIO::reset` resets the pipeline before releasing the resources for the same reason. The memory reservation feature (#82414) was backported to 26.6 in `2098704e6d1` on 2026-06-27, but this fix never followed: its cherry-pick #108562 was closed automatically on 2026-07-06 with unresolved conflicts. As a result 26.6 reports the race in `Stress test (amd_tsan)`, for example https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112727&sha=6120a6fb27efe0d740c8f075aee499215d2f23e1&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29
|
Workflow [BackportPR], commit [73ef825] Summary: ✅ |
|
🕵 Re-merged Both reds on the previous head
@groeneai, could you take care of backporting #102033 to |
|
Yes, but via the label route rather than a hand-authored PR: on #111910 you told me "No need to hand-author anything ... I posted that ask on #102033 42 minutes before your comment here, so the two likely crossed: #102033 (comment) One refinement to it. Please apply Feasibility is measured: simulating the cherry-pick the way |
|
🕵 Re-merged The only red on the previous head |
|
🕵 Re-merged Both reds on the previous head
No review threads and no AI-review verdict. Everything else is green. |
|
🕵 Re-merged The only red on the previous head No review threads and no AI-review verdict. Everything else is green. |
|
🕵 Re-merged The only red on the previous head |
… on the previous push
|
🕵 The The only red on the last completed run ( |
|
🕵 Re-merged The only red on the previous head |
|
🕵 Re-merged The only red on the previous head |
Manual backport of #108391 ("Fix data race on
MemoryReservationrelease at query finish") to26.6.BlockIO::onFinishreleased all workload resources — including theMemoryReservation— before the query pipeline was finalized, while pipeline threads still hold raw pointers to it throughWorkloadResourcesinPipelineExecutor. The release is now split: the query slot is released early (safe, pipeline threads never touch it), and the memory reservation only after the pipeline has been finalized and its threads joined.BlockIO::resetresets the pipeline before releasing the resources for the same reason.Motivation: the memory reservation feature (#82414) was backported to
26.6in2098704e6d1on 2026-06-27, but this fix never followed — its cherry-pick #108562 was closed automatically on 2026-07-06 with unresolved conflicts. As a result26.6reports the following TSan race inStress test (amd_tsan)and reddens unrelated26.6backport PRs (found on #112727):CI report with the race: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112727&sha=6120a6fb27efe0d740c8f075aee499215d2f23e1&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29
The diff is identical to the one merged on
master(it applies to26.6cleanly now that #82414 has been backported).Changelog category (leave one):
Documentation entry for user-facing changes