Mryange opened a new pull request, #71260: URL: https://github.com/apache/doris/pull/71260
### Background The BE receives its ID from FE heartbeats and uses it in reports, load requests, and WAL file names. Heartbeat maintained two local copies of that ID. ### What problem does this PR solve? Issue Number: None Related PR: #35634 (introduced the BackendOptions copy), #41994 (introduced the ClusterInfo copy) PR Type: Bugfix Problem Summary: ThreadSanitizer reported races between heartbeat writes and background reads of the BE ID. This change stores the ID in one atomic variable and routes local consumers through the same accessor. ### Details - **Frequency:** Intermittent when a heartbeat carrying the BE ID overlaps an unsynchronized read. - **Root cause:** Heartbeat wrote two plain integers while holding its own mutex. Report and compaction threads read those integers without acquiring that mutex. - **Why existing tests missed it:** The heartbeat unit test checks token handling and the WAL unit test checks replay. The P0 regression run with ThreadSanitizer surfaced the overlap between heartbeat and background readers. - **Fix:** Keep the ID in BackendOptions. The getter uses the default atomic load and heartbeat uses a relaxed store because the ID does not publish other state. Each optional RPC field is checked and populated from a single read. - **Other paths and branches:** Migrate the remaining local readers, including load, WAL, query statistics, and information schema. Both 4.1 and 4.2 contain the duplicate writes, and a direct cherry-pick conflicts on both branches. ### Testing Added a heartbeat unit test for omitted and supplied IDs and updated the WAL test fixture. The BE build, unit tests, and post-fix ThreadSanitizer run are pending. ### Release note None. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: BE build, unit tests, and post-fix ThreadSanitizer were not run. ### AI Disclosure - Tool: Codex - Generated: Code, unit test, and PR description - Human review: The author reviewed the candidate and requested the implicit atomic getter before approving the revised diff. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
