Repository navigation
Conversation
|
Workflow [PR], commit [c1a2f73] Summary: ✅
AI ReviewSummaryThis PR adds a second acquire load of Findings
Tests
Performance & Safety
Final VerdictStatus: Minimum required actions: remove or gate the production hot-path checks, and provide evidence that the selected TSan mitigation actually addresses the reported failure mode. If keeping release-build checks, provide performance data and justify the |
| /// (slot.pos - i) parity to odd. | ||
| /// * tryPop symmetrically does slot.pos.load(acquire), checks that parity is odd, | ||
| /// does the read, does slot.pos.store(release) that flips parity back to even. | ||
| size_t slot_pos_again = slot.pos.load(std::memory_order_acquire); |
There was a problem hiding this comment.
This PR is trying to work around a TSan-only report, but this check runs in every release build too. NonblockingBoundedQueue is explicitly a high-throughput queue and tryPush/tryPop are on Keeper request/response paths, so adding an acquire load, plus a release-build std::abort path, to every successful operation changes production behavior without evidence that production needs it. Please either gate the extra loads/checks under THREAD_SANITIZER/DEBUG_OR_SANITIZER_BUILD, or include a benchmark/justification showing the unconditional cost and abort semantics are acceptable. The same applies to the matching check in tryPop.
|
I got the same from my investigation here is AI summary of it: The failuresFour Keeper TSan CI runs (PRs 106185, 106178, 105891, 97676) all report the same race, The race: Root cause: a benign TSan false positive
Likely mechanism (thread recycling)The producers are short-lived, per-connection Poco worker threads: a producer does the On PR #106801 ("Try to do something about TSAN error") — not a good solutionThe PR (by the queue's author, self-described "desperate hack") adds a second
Recommended fixA suppression, not a runtime hack (infra confirmed: Use CaveatsMemory-model and call-site verdicts are proven from source. The exact TSan lost-edge trigger |
|
I couldn't get claude to reproduce it though, so I don't trust the theory about what exactly goes wrong in TSAN. Still a chance the bug is in NonblockingBoundedQueue. The idea for second load is that maybe TSAN gets confused by the |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 23/24 (95.83%) | Lost baseline coverage: none · Uncovered code |
|
In any case, our theory is that we have a false positive in TSAN. I would prefer explicitly disabling the check over doing hacks to make it work. |
|
Ok, let's do #107083 instead. I don't mind because the current PR seems unlikely to work. I still think tweaking the code would be better, if it made TSAN pass, because that would provide strong additional evidence that there really isn't a data race (either because the original error was a false positive or because the change accidentally fixed a real race). |
Changelog category (leave one):
A perplexing TSAN error. I didn't figure out the cause. Happened ~6 times over 2 weeks, in different integration tests.
https://play.clickhouse.com/play?user=play#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIHRlc3RfbmFtZSwgcHVsbF9yZXF1ZXN0X251bWJlciwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSBjaGVja19zdGFydF90aW1lID49IG5vdygpIC0gSU5URVJWQUwgMzAgREFZCiAgQU5EIGNoZWNrX25hbWUgSUxJS0UgJyVJbnRlZ3JhdGlvbiUnCiAgQU5EIHRlc3RfY29udGV4dF9yYXcgTElLRSAnJVNhbml0aXplciBhc3NlcnQgZm91bmQgZm9yIGluc3RhbmNlIHpvbyUnCiAgYW5kIGJhc2VfcmVmID0gJ21hc3RlcicKICBhbmQgcHVsbF9yZXF1ZXN0X251bWJlciAhPSAxMDE3NTcKT1JERVIgQlkgY2hlY2tfc3RhcnRfdGltZSBERVND
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106185&sha=fb27559f055b68972384718352e7c41b809441b3&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%206%2F6%29&name_1=Integration%20tests%20%28amd_tsan%2C%206%2F6%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106178&sha=413c4041a85f2652834a98bfbbc57e163673601b&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=105891&sha=775580d0e4e076b016a615cd1fee61e5fc640d17&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%201%2F6%29&name_1=Integration%20tests%20%28amd_tsan%2C%201%2F6%29
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97676&sha=8e774bd9e9054aaae7708ffad555f15c570c77ae&name_0=PR&name_1=Integration%20tests%20%28amd_tsan%2C%205%2F6%29&name_1=Integration%20tests%20%28amd_tsan%2C%205%2F6%29
(etc)
TSAN says data race in NonblockingBoundedQueue between writing
slot.valueintryPushand readingslot.valueintryPopfrom another thread. I.e. exactly the normal usage of the queue, exactly the race the queue's fancy atomics with fancy memory_orders are meant to prevent.So, I'm confused and ran out of plausible hypotheses. Maybe I'm just being silly and there's an obvious bug.
Here's a desperate PR that adds another atomic load to (a) explicitly re-check the invariant and possibly crash if the code is actually wrong, (b) possibly work around TSAN problem.