Repository navigation
Backport the NonblockingBoundedQueue TSAN suppression to 26.6 - #112912
Conversation
Backport of ClickHouse#112695 to 26.6, requested by alexey-milovidov on ClickHouse#112722. 26.6 still carries the defect and has no fix. `Integration tests (amd_tsan, N/6)` fails in teardown with `Sanitizer assert found for instance zoo<N>`, from a TSAN data race report between the `slot.value` write in `NonblockingBoundedQueue::tryPush` and the read in `tryPop`. The report is a false positive. The release/acquire handoff on `slot.pos` orders every access to a slot payload, and there is no non-protocol payload access anywhere in the class, so the code is isomorphic to Vyukov's original implementation. But `abort_on_error=1` in `__tsan_default_options` turns the report into an aborted Keeper node, so healthy runs go red. A `NO_SANITIZE_THREAD` attribute cannot suppress it. Neither `KeeperRequestForSession` nor `KeeperResponseForSession` declares an `operator=`, so the racing access happens in the implicitly generated move assignment, a separate function that keeps `sanitize_thread`. The attribute also prevents that un-attributed callee from being inlined into the attributed caller, which is what creates the frame split that defeats it. A runtime `__tsan_default_suppressions` entry is consulted for every frame of a report, so one entry covers the whole nested move chain. Register that hook with two anchored patterns for the two Keeper instantiations. Only `tryPush` is listed: the `dequeue_pos` compare-exchange gives one consumer sole ownership of a slot before the move-out in `tryPop`, so a pop/pop payload race cannot occur at any consumer count, and each `race:` entry also hides heap-use-after-free reports through the frame it names. Anchoring is load-bearing. Patterns are matched against each frame's function, file and module name, and `clickhouse-keeper-bench` is a symlink to the same binary, so an unqualified pattern would also silence its three unrelated `NonblockingBoundedQueue<QueueItem>` queues. Verified it does not. This is purely additive, unlike the master commit: ClickHouse#107083, which added the attributes master removes, was never backported to 26.6, so there is no attribute to strip here. A straight cherry-pick does not apply (`git apply --check` fails on both files); on 26.6 the hook goes in `base/base/sanitizer_options.h`, which is master's own placement, whereas the 26.5 sibling ClickHouse#112899 had to use `programs/main.cpp` because that header does not exist on 26.5. Non-sanitizer builds are unaffected: the hook is inside `#ifdef THREAD_SANITIZER` and the other change is a comment, so there is no codegen change and no performance impact. A suppression only affects whether TSAN prints or aborts on a report. No test, matching ClickHouse#112695. The only oracle is a CI-side absence property over many runs, which no functional test can assert. Co-Authored-By: Claude Fable 5 <[email protected]>
Internal second-model review (independent reviewer + Gate B, 3 rounds, $30.20)This change was reviewed by a reviewer independent of the author, then by a second model
No blocker or major was raised in either review. The two nits and the reformulated third were What the independent review verified against the source, rather than accepting from the
Gate B was run with an explicitly supplied Session id: cron:clickhouse-review-slot-52:20260801-141502 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-45:20260801-132600 |
|
cc @alesapin, could you review this? It is the 26.6 backport of the already-merged #112695: a runtime |
|
Workflow [BackportPR], commit [4350474] Summary: ❌
|
CI finish ledger - 4350474Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
The other 35 completed check-runs on this commit are green ( Session id: cron:our-pr-ci-monitor:20260801-190047 |
|
Fixing PR for the Root cause: the job runs a nested Docker daemon under |
Related: #112695
Related: #112722
Related: #112899
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Backport of #112695 to
26.6, requested on #112722.26.6still carries the defect.Integration tests (amd_tsan, N/6)fails in teardown withSanitizer assert found for instance zoo<N>, from a TSAN data race report between theslot.valuewrite inNonblockingBoundedQueue::tryPushand the read intryPop. The report is a false positive: the release/acquire handoff onslot.posorders every access to a slot payload, and the class has no non-protocol payload access. Butabort_on_error=1aborts the Keeper node, so healthy runs turn red.A
NO_SANITIZE_THREADattribute cannot suppress it. Neither element type declares anoperator=, so the racing access happens in the implicitly generated move assignment, a separate function that stays instrumented. A runtime__tsan_default_suppressionsentry is consulted for every frame of a report, so one entry covers the whole nested move chain.This registers that hook with two anchored patterns for the two Keeper instantiations. Only
tryPushis listed: thedequeue_posCAS gives one consumer sole ownership of a slot beforetryPop's move-out, so a pop/pop payload race cannot occur at any consumer count, and arace:entry also hides heap-use-after-free through the frame it names. Anchoring keeps them off the unrelatedkeeper-benchqueues in the same binary.Purely additive, and sanitizer builds only (no performance impact): Suppress TSAN error in NonblockingBoundedQueue #107083, whose attributes master's commit removes, was never backported here, and the hook is inside
#ifdef THREAD_SANITIZER.A cherry-pick does not apply (
git apply --checkfails on both files). On26.6the hook goes inbase/base/sanitizer_options.h, master's own placement; that header does not exist on26.5, which is why Backport the runtime TSAN suppression forNonblockingBoundedQueueto 26.5 #112899 had to put the hook inprograms/main.cppinstead.No test, matching Fix the ineffective TSAN suppression in
NonblockingBoundedQueue#112695: the only oracle is a CI-side absence property over many runs.The label route was unavailable: Fix the ineffective TSAN suppression in
NonblockingBoundedQueue#112695 has no*-must-backportlabel, and the robot cherry-picks.Verification (26.6, TSAN build, clang-21)
Built
-DCMAKE_BUILD_TYPE=None -DSANITIZE=thread(theamd_tsanshape). Both directions, on the real binary:nm -CT countThe weak fallback is why a bare
grepfor the symbol is not a valid check.clickhouse-keeperis a symlink to themain.cpp-built binary (BUILD_STANDALONE_KEEPERis off in the TSAN builds), so the hook is linked into the Keeper process, and the runtime loads the strings without a parse error.A standalone TSAN probe, taking the hook from the real header, confirms behavior on three arms:
KeeperRequestForSessionsuppressed,KeeperResponseForSessionsuppressed,QueueItem(the keeper-bench shape) still reported. Mangling the category tobogusrace:makes TSAN answer "failed to parse suppressions", proving the runtime consumes the string rather than ignoring it.Version info
26.6.5.48