Repository navigation
mgr/DaemonServer: fix race conditions and resource leaks in shutdown() - #71234
Merged
stzuraski898 merged 1 commit intoSep 17, 2026
Merged
stzuraski898 merged 1 commit into
stzuraski898 merged 1 commit into
Conversation
Unit testing revealed that DaemonServer::shutdown() had bugs that could cause crashes during MGR daemon shutdown and failover: 1. The SafeTimer thread was never joined before destruction. With safe_callbacks=true (the default), timer.shutdown() must be called under the DaemonServer lock so that it can join the timer thread cleanly. Inflight timer callbacks could also invoke virtual methods on a partially destroyed object, causing "pure virtual method called" errors. 2. The admin socket hook registered in init() was never unregistered or freed, leaving the admin socket with a dangling pointer to the destroyed DaemonServer. 3. msgr was deleted directly without calling shutdown()+wait() first, racing the messenger dispatch thread against object destruction. Fix shutdown() to: join the timer under the lock; unregister and delete asok_hook; call msgr->shutdown()+wait() before deleting msgr; and clear the handle_authentication_dispatcher pointer in monc after msgr is fully stopped (msgr is monc's auth server, so no new auth requests can arrive on monc once msgr is joined). Guard both dereferences of handle_authentication_dispatcher in MonClient::handle_auth_request() against nullptr, so that connections arriving in the brief window between MGR deactivation and the next activation are rejected cleanly via handle_auth_failure() rather than crashing. Fixes: https://tracker.ceph.com/issues/76335 Signed-off-by: stzuraski898 <[email protected]> Assisted by: IBM Bob
stzuraski898
force-pushed
the
wip-sz-76335-daemonserver-object-cleanup
branch
from
August 21, 2026 22:27
e142437 to
00c50ec
Compare
Contributor
|
This PR has been added to wip-bharath3-testing-20260824.233415-main. |
Contributor
Author
|
jenkins test api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unit testing revealed that DaemonServer::shutdown() had bugs that could cause crashes during MGR daemon shutdown and failover:
The SafeTimer thread was never joined before destruction. With safe_callbacks=true (the default), timer.shutdown() must be called under the DaemonServer lock so that it can join the timer thread cleanly. Inflight timer callbacks could also invoke virtual methods on a partially destroyed object, causing "pure virtual method called" errors.
The admin socket hook registered in init() was never unregistered or freed, leaving the admin socket with a dangling pointer to the destroyed DaemonServer.
msgr was deleted directly without calling shutdown()+wait() first, racing the messenger dispatch thread against object destruction.
Fix shutdown() to: join the timer under the lock; unregister and delete asok_hook; call msgr->shutdown()+wait() before deleting msgr; and clear the handle_authentication_dispatcher pointer in monc after msgr is fully stopped (msgr is monc's auth server, so no new auth requests can arrive on monc once msgr is joined).
Guard both dereferences of handle_authentication_dispatcher in MonClient::handle_auth_request() against nullptr, so that connections arriving in the brief window between MGR deactivation and the next activation are rejected cleanly via handle_auth_failure() rather than crashing.
Fixes: https://tracker.ceph.com/issues/76335
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.