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 <dongdong.tao@canonical.com>
(cherry picked from commit
30d66ff075ca72c0c3759bfccee09302b221b25f)
}
}
+void CephContext::drop_temp_messenger_obj()
+{
+ auto i = associated_objs.begin();
+ while (i != associated_objs.end()) {
+ if (i->first.first.find("AsyncMessenger::NetworkStack") != std::string::npos) {
+ i = associated_objs.erase(i);
+ break;
+ } else {
+ ++i;
+ }
+ }
+}
+
void CephContext::notify_pre_fork()
{
{
_fork_watchers.push_back(w);
}
+ void drop_temp_messenger_obj();
void notify_pre_fork();
void notify_post_fork();
chown_path(conf->pid_file, cct->get_set_uid(), cct->get_set_gid(),
cct->get_set_uid_string(), cct->get_set_gid_string());
}
-
+ cct->drop_temp_messenger_obj();
return -1;
}