Skip to content

common: fix the ms_async_op_threads not applied successfully for daemons running in foreground mode - #63390

Merged
SrinivasaBharath merged 1 commit into
ceph:mainfrom
taodd:fix-ms_async_op_threads
Nov 20, 2025
Merged

SrinivasaBharath merged 1 commit into
ceph:mainfrom
taodd:fix-ms_async_op_threads

Conversation

@taodd

@taodd taodd commented May 21, 2025

Copy link
Copy Markdown
Contributor

During the initialization, OSD needs to create a temporary messenger to read config db from the ceph-mon. This temporary messenger will need to create async messenger threads according to the local/default value of "ms_async_op_threads" . If this option is not specified in ceph.conf, it will by default create 3 threads, then use these threads to read config db from ceph-mon. Those threads are associated to a stack singletion object. Now here is the difference between OSD running in foreground and background: a. In background mode, this singleton object will be dropped before forking the child process in function notify_pre_fork, then the new ms_async_op_threads fetched from mon config db will be used to create later messenger threads, this is what we want. b. In foreground mode, this singleton object will not be dropped and will be reused by all later messengers, thus the number of threads doesn't change.

fixes: https://tracker.ceph.com/issues/71401

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

@taodd taodd changed the title common: drop stack singleton object of temp messenger for foreground … common: drop stack singleton object of temp messenger for foreground daemon May 21, 2025
@taodd taodd changed the title common: drop stack singleton object of temp messenger for foreground daemon common: fix the ms_async_op_threads not applied successfully for daemons running in foreground mode May 21, 2025
@taodd
taodd force-pushed the fix-ms_async_op_threads branch from 9f7a6ed to b11cb0a Compare May 21, 2025 10:06

@rzarzynski rzarzynski 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.

Almost LGTM; just a nit.

Comment thread src/common/ceph_context.cc Outdated

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.

Yeah, before forking we do:

void CephContext::notify_pre_fork()
{
  {
    std::lock_guard lg(_fork_watchers_lock);
    for (auto &&t : _fork_watchers) {
      t->handle_pre_fork();
    }
  }
  {
    // note: we don't hold a lock here, but we assume we are idle at
    // fork time, which happens during process init and startup.
    auto i = associated_objs.begin();
    while (i != associated_objs.end()) {
      if (associated_objs_drop_on_fork.count(i->first.first)) {
        i = associated_objs.erase(i);
      } else {
        ++i;
      }
    }
    associated_objs_drop_on_fork.clear();
  }
}

Comment thread src/common/ceph_context.cc Outdated

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.

nit: unneeded space.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

deleted, thanks!

…ceph daemons

During the initialization, OSD needs to create a temporary messenger to read config db from the ceph-mon.
This temporary messenger will need to create async messenger threads according to the local/default value of "ms_async_op_threads" .
If this option is not specified in ceph.conf, it will by default create 3 threads, then use these threads to read config db from ceph-mon.
Those threads are associated to a stack singletion object.
Now here is the difference between OSD running in foreground and background:
a. In background mode, this singleton object will be dropped before forking the child process in function notify_pre_fork,
then the new ms_async_op_threads fetched from mon config db will be used to create later messenger threads, this is what we want.
b. In foreground mode, this singleton object will not be dropped and will be reused by all later messengers,
thus the number of threads doesn't change.

Fixes: https://tracker.ceph.com/issues/71401
Signed-off-by: dongdong tao <[email protected]>
@taodd
taodd force-pushed the fix-ms_async_op_threads branch from b11cb0a to 30d66ff Compare June 4, 2025 02:09

@pponnuvel pponnuvel 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

@github-actions

github-actions Bot commented Aug 3, 2025

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Aug 3, 2025
@taodd

taodd commented Aug 7, 2025

Copy link
Copy Markdown
Contributor Author

@rzarzynski could you help take another look?

@github-actions github-actions Bot removed the stale label Aug 7, 2025
@ljflores
ljflores requested a review from rzarzynski September 29, 2025 19:42
@sseshasa

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/19524491105

@taodd

taodd commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

Hello @sseshasa @rzarzynski , this patch should be backported, could you help to change the state of bug https://tracker.ceph.com/issues/71401 to pending backport state ?

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.

6 participants