Repository navigation
Fix TSan data race on NuRaft peer config_ - #107429
alexey-milovidov wants to merge 2 commits into
Conversation
Bump the `NuRaft` submodule to pick up a fix for a ThreadSanitizer data race on `nuraft::srv_config::get_id`. It was reported by the `amd_tsan` integration test `test_keeper_4lw_reconfiguration::test.py::test_precondition_failure` on master. The `peer::config_` member is protected by `config_mutex_` and should be read only through the locked accessors, but several call sites in `peer.cxx` read `config_->get_id` directly. ThreadSanitizer caught a race between the unlocked read in `peer::handle_rpc_result` (an asio RPC worker) and the construction of a fresh `srv_config` published via `peer::set_config` while `cluster_config::deserialize` runs inside `raft_server::commit_conf` on the commit thread. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=df91f51b4c94124eac71ce4b15549248d13dc42a&name_0=MasterCI&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [66a87ef] Summary: ❌
AI ReviewSummary
Findings
Tests
Final Verdict
|
NuRaft PR #119 has been merged. Move the submodule pointer from the fix commit to the fork's `master` tip (the merge commit), so it tracks master rather than a feature branch. ClickHouse/NuRaft#119 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| @@ -1 +1 @@ | |||
| Subproject commit c3d2e767add589ef4276577cd89df969649fdf4f | |||
| Subproject commit 131671cbfb7c3568ce2b9300c35e945833a164d0 | |||
There was a problem hiding this comment.
This NuRaft revision still leaves the same peer::config_ race on another accessor. The patch replaces direct config_->get_id reads in peer.cxx, but include/libnuraft/peer.hxx:114 still implements peer::is_new_joiner as an unlocked return config_->is_new_joiner();. That accessor is reached from raft_server::is_regular_member in vote/append paths without peer::lock_ (for example src/handle_vote.cxx:53 and src/handle_append_entries.cxx:1801), while config commit can concurrently run pp->set_config(entry) at src/handle_commit.cxx:1171. Since ptr is std::shared_ptr, that unlocked read races with the assignment to the same config_ member, so this bump does not fully satisfy the "all peer::config_ reads go through locked accessors" contract. Please update the upstream fix so peer::is_new_joiner also locks or copies under config_mutex_ before bumping the submodule.
|
@groeneai, fix |
|
@alexey-milovidov done on the first one; the second is a separate (rare) issue.
reached via For the mongo one, which would you prefer:
(1) is low-risk and immediate; (2) is the real fix but slower and touches a submodule. I will take whichever you want. |
|
@groeneai, We have to fix it, even if it is a bug inside the Mongo C library. |
Done. The
Root cause: Verified both directions with a standalone ASan/LSan harness driving the real |
|
Included in #107338 |
Related: ClickHouse/NuRaft#119
Bumps the
NuRaftsubmodule to fix a ThreadSanitizer data race onnuraft::srv_config::get_id, reported by theamd_tsanintegration testtest_keeper_4lw_reconfiguration::test.py::test_precondition_failureon master.The
peer::config_member is protected byconfig_mutex_and is meant to be read only through the locked accessors. Several call sites inpeer.cxxstill readconfig_->get_iddirectly, bypassing the mutex. ThreadSanitizer caught a race between the unlocked read inpeer::handle_rpc_result(an asio RPC worker thread) and the construction of a freshsrv_configpublished viapeer::set_configwhilecluster_config::deserializeruns insideraft_server::commit_confon the commit thread. The fix routes those reads through the lockedget_idaccessor.This is a rare race: 1 failure in 144 master runs on the day it surfaced, and 0 in the preceding 30 days. No existing tracking issue was found.
CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=df91f51b4c94124eac71ce4b15549248d13dc42a&name_0=MasterCI&name_1=Integration%20tests%20%28amd_tsan%2C%204%2F6%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a ThreadSanitizer data race on the per-peer config in the embedded Raft library (Keeper).