Repository navigation
Widen the Keeper request-size TSan suppression to the whole bytesSize subtree - #115524
Conversation
…e` subtree On `amd_tsan` integration shards the Keeper container occasionally writes a ThreadSanitizer report for the request the dispatch thread just popped, which aborts the container. `helpers/cluster.py` then raises `Sanitizer assert found for instance zooN` during `cluster.shutdown()`, and whichever test happened to run last goes red; the victim is incidental. There is no real race: `KeeperTCPHandler::receiveRequest` writes every payload field of the request before publishing it with `putRequest`, and `getRequestBytesCost` on the consumer side only reads the vptr and those fields. The existing entry was added as `race_top:^DB::getRequestBytesCost`, which matches the innermost frame only. That covered the vptr read, attributed to the call site inside `getRequestBytesCost` - but suppressing it just moved the report one frame down, to the `path` read inside `Coordination::GetRequest::bytesSize`, which aborts the container all the same. Use `race:` so the entry covers the whole callee subtree; that subtree is only `bytesSize`, a read-only size computation. Validated against the real ThreadSanitizer runtime with a harness that reproduces both frame shapes (arms differ only in the string returned by `__tsan_default_suppressions`; `banner` counts runs printing the `==================` line the integration harness greps for): | suppression | vptr shape | `bytesSize` shape | |--------------------------------------------|------------|-------------------| | (empty) | 8/10 | 10/10 | | `race_top:^DB::getRequestBytesCost` | 8/10 | 9/10 | | `race:^DB::getRequestBytesCost` | 0/20 | 0/20 | With `race_top:` the surviving report is exactly the one master hit: the `path.size()` read inside `bytesSize`, one frame below `getRequestBytesCost`. Controls: a typo'd pattern parses but suppresses nothing (10/10 banner), a mangled type token makes the runtime die with `failed to parse suppressions`, and `print_suppressions=1` shows the new entry being hit. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=dddf61ccff5828bb6937cfe680874a04be35932f&name_0=MasterCI&name_1=Integration%20tests%20%28amd_tsan%2C%206%2F6%29 Related: #113552 Related: #112695 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [c8f8e77] Summary: ✅
AI ReviewSummaryThis PR widens the Keeper ThreadSanitizer suppression from Findings
Final Verdict
|
| return "race:^NonblockingBoundedQueue<DB::KeeperRequestForSession>::tryPush\n" | ||
| "race:^NonblockingBoundedQueue<DB::KeeperResponseForSession>::tryPush\n" | ||
| "race_top:^DB::getRequestBytesCost\n"; | ||
| "race:^DB::getRequestBytesCost\n"; |
There was a problem hiding this comment.
race_top:^DB::getRequestBytesCost only blinded the vptr false positive at the call site. This change to race:^DB::getRequestBytesCost suppresses every report from every request type's bytesSize() subtree instead.
That is wider than the safety argument in the new comment. After the suppressed read in tryPopRequest, the dispatcher can immediately drop the request on the dead-session path (src/Coordination/KeeperRequestDispatcher.cpp:857-866) or the soft-memory rejection path (src/Coordination/KeeperRequestDispatcher.cpp:878-889). Those paths never touch GetRequest::path again, so a real lifetime/race bug in Coordination::*Request::bytesSize would now be fully hidden instead of surfacing on a later unsuppressed access.
Can we keep this narrow by suppressing the concrete Coordination::*Request::bytesSize frame(s) from the report, rather than every stack that passes through DB::getRequestBytesCost?
There was a problem hiding this comment.
I strongly dislike the fact that Keeper required TSan suppressions. All the ClickHouse codebase, which is 100x larger, never required that. However, I trust the engineers of Keeper and find this tolerable.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
Related: #113552
Related: #112695
On
amd_tsanintegration shards the Keeper container occasionally writes a ThreadSanitizer report for the request the dispatch thread just popped, which aborts the container.helpers/cluster.pythen raisesSanitizer assert found for instance zooNduringcluster.shutdown(), and whichever test happened to run last goes red - the victim is incidental. This time it wastest_database_replicated_settings/test.py::test_database_replicated_with_internal_replication[1-1]:CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=dddf61ccff5828bb6937cfe680874a04be35932f&name_0=MasterCI&name_1=Integration%20tests%20%28amd_tsan%2C%206%2F6%29
There is no real race.
KeeperTCPHandler::receiveRequestwrites every payload field of the request -xid, thenreadImpl, then the tracing context - before publishing it withputRequest; the only post-publication write is on the consumer's own side.getRequestBytesCostreads the vptr and those fields.#113552 added the entry for this report as
race_top:^DB::getRequestBytesCost.race_top:matches the innermost frame only, so it covered the vptr read, which ThreadSanitizer attributes to the call site insidegetRequestBytesCost. Suppressing that does not stop the run: the very next racy access is thepathread insideCoordination::GetRequest::bytesSize, one frame below, and it aborts the container all the same. That is the report above. So this switches the entry torace:, which matches any frame and therefore covers the whole callee subtree. The subtree is onlybytesSize, a read-only size computation, and a use-after-free blinded there still surfaces on the next access to the same request indispatchThread.Validation
Against the real ThreadSanitizer runtime, with a harness whose handoff is deliberately unsynchronized so a report is produced on every run and the only variable is which patterns match the frame shape. Arms differ only in the string returned by
__tsan_default_suppressions.bannercounts runs printing the==================line, which is exactly what the integration harness greps to raise the assert.bytesSizeshape (this report)race_top:^DB::getRequestBytesCostrace:^DB::getRequestBytesCostIn the
race_top:/ vptr-shape cell the surviving report is exactly the one master hit:race_top:suppresses the vptr read, the run continues, and thepath.size()read insidebytesSizeis reported instead.Controls: a typo'd pattern (
race:^DB::getRequestBytesCostXX) parses but suppresses nothing (10/10 banner), so the entry's liveness is not assumed; a mangled type token (raceX:) makes the runtime die withfailed to parse suppressions, confirming this hook is the live channel;print_suppressions=1shows the new entry being hit.ci/jobs/scripts/check_style/check_cpp.shpasses. Non-TSan builds are unaffected - the hook is inside#ifdef THREAD_SANITIZER.Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/115524]