Repository navigation
common,mon,mgr,mds: exec the binary on disk when respawning - #72805
Merged
Merged
Conversation
Contributor
Author
|
jenkins test make check |
NitzanMordhai
approved these changes
Oct 19, 2026
NitzanMordhai
left a comment
Contributor
There was a problem hiding this comment.
@tchaikov please see my comment, other than that nit , LGTM
respawn() execs /proc/self/exe rather than the path it points to, so that it works after the executable is unlinked. Replacing the binary unlinks it too, so after an upgrade the re-exec runs the old image against libceph-common.so and the rest as replaced on disk: either a symbol lookup error, as in ceph#41513, or old code on new libraries. execv() keeps the pid, so the service manager sees nothing. Exec the path instead, less the " (deleted)" marker the kernel appends. If nothing is there any more, because the binary was removed rather than replaced, execv() fails and respawn() reports it like any other exec failure. The daemon therefore adopts a new binary without an operator-initiated restart. It has to exec something and the alternative is an image whose libraries are gone, so that is the lesser evil. Exiting and leaving the restart to the service manager would be the deeper fix, but not for deployments without one. mon, mgr and mds each had a copy of the decision, so it now sits next to unblock_all_signals(), which the same three use. Fixes: https://tracker.ceph.com/issues/81856 Related-to: https://tracker.ceph.com/issues/41513 Signed-off-by: Kefu Chai <[email protected]>
Only rbd on Windows calls get_self_exe_path(), from a block guarded by _WIN32, so the POSIX implementation has no caller at all. That is how it stayed unnoticed that it hands readlink() sizeof(buff_length), the size of the int parameter rather than the size of the buffer, and so never returned more than three bytes of the path. compat.h is there to let shared code build on Windows, and this is not shared code. Call GetModuleFileName() from the caller instead, the way the POSIX counterpart in Nbd.cc calls readlink() directly, and drop the shim. GetModuleFileName() reports failure as 0 rather than -1, and the shim passed that through unchanged, so the test for a negative length could never fire and the rbd-wnbd fallback was unreachable. Test for 0. Signed-off-by: Kefu Chai <[email protected]>
tchaikov
force-pushed
the
wip-respawn-exec-binary-on-disk
branch
from
October 20, 2026 11:45
87c45da to
aad798d
Compare
Contributor
Author
|
changelog
|
Contributor
|
This PR has been added to wip-bharath10-testing-20261027.070130-main. |
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.
respawn()reads/proc/self/exeand execs that symlink rather than the path it points to, so that a respawn works after the executable is unlinked. Replacing the binary unlinks it too, so after a package upgrade the re-execruns the old image while the dynamic linker loads
libceph-common.soand the rest from disk, where the upgrade replaced them. The daemon either exits with a symbol lookup error, as in #41513, or runs old code against new libraries, andexecv()keeps the pid, so the service manager sees no state change and keeps reporting the unit healthy.The first commit execs the binary at its original path instead, less the
" (deleted)"marker the kernel appends, and keeps the decision in one place next tounblock_all_signals(), which mon, mgr and mds already use. If nothingis at the path any more, because the binary was removed rather than replaced,
execv()fails andrespawn()reports it like any other exec failure.#41513 reported this in 2019 and was closed with a QA change, 4205964, so squid, tentacle and umbrella all still have it. A daemon respawns with the code it is running, so the fix only helps on an upgrade out of a release that already carries it, hence the backports on the tracker.
What reaches this on every major upgrade is a separate defect, fixed by #72804: the first monitor of the new release to become leader rewrites
always_on_modulesin the mgrmap and every manager treats that as a change toits own module set and respawns. Either fix alone leaves a hole, since other respawn triggers (an MDS blocklisted or timed out, a manager losing active status) can land in the same window.
Fixes: https://tracker.ceph.com/issues/81856
Checklist