Skip to content

msg/async: make Worker::done atomic - #73713

Open
Doracly wants to merge 1 commit into
ceph:mainfrom
Doracly:TSan-msg
Open

Doracly wants to merge 1 commit into
ceph:mainfrom
Doracly:TSan-msg

Conversation

@Doracly

@Doracly Doracly commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Fixes a data race that ThreadSanitizer reports in 2 unit tests (2 reports, now 0). Split from #72460.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

NetworkStack::stop() sets done while the worker loop in
NetworkStack::add_thread() polls it:

    WARNING: ThreadSanitizer: data race
      Write of size 1 by main thread:
        #0 NetworkStack::stop() src/msg/async/Stack.cc:165
        ceph#1 StackSingleton::~StackSingleton() src/msg/async/AsyncMessenger.cc:268
      Previous read of size 1 by thread T4:
        #0 operator() src/msg/async/Stack.cc:46
      Thread T4 'msgr-worker-0' created by main thread

Relaxed ordering is enough: done guards no other data, and stop()
joins the worker.

Assisted-by: claude-opus-5-5
Signed-off-by: Dominik Raddatz <[email protected]>
@Doracly
Doracly requested a review from a team as a code owner November 10, 2026 08:41
@github-actions github-actions Bot added the core label Nov 10, 2026
@Doracly
Doracly requested review from dvanders and idryomov and removed request for dvanders November 10, 2026 08:51

@dvanders dvanders left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. done is only touched in three places: the worker loop in add_thread(), stop(), and Worker::reset(), which runs on the worker thread after the loop exits. stop() joins each worker right after setting the flag, so relaxed ordering is enough. The worker re-reads the flag after center.wakeup(), or at worst when the 30 s process_events() timeout expires. <atomic> is already included in Stack.h.

@Doracly
Doracly requested review from tchaikov and removed request for tchaikov November 13, 2026 11:32
@Doracly

Doracly commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@idryomov @dvanders thanks for the reviews! Could one of you add needs-qa?

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath24-testing-20261114.234450-main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants