Skip to content

common,mon,mgr,mds: exec the binary on disk when respawning - #72805

Merged
tchaikov merged 2 commits into
ceph:mainfrom
tchaikov:wip-respawn-exec-binary-on-disk
Nov 5, 2026
Merged

tchaikov merged 2 commits into
ceph:mainfrom
tchaikov:wip-respawn-exec-binary-on-disk

Conversation

@tchaikov

@tchaikov tchaikov commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

respawn() reads /proc/self/exe and 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-exec
runs the old image while the dynamic linker loads libceph-common.so and 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, and execv() 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 to unblock_all_signals(), which mon, mgr and mds already use. If nothing
is at the path any more, because the binary was removed rather than replaced, execv() fails and respawn() 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_modules in the mgrmap and every manager treats that as a change to
its 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

  • 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)
    • Includes unit test(s)
    • Includes integration test(s)
    • Includes bug reproducer
    • No tests

@tchaikov

Copy link
Copy Markdown
Contributor Author

jenkins test make check

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

@tchaikov please see my comment, other than that nit , LGTM

Comment thread src/mon/Monitor.cc Resolved
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
tchaikov force-pushed the wip-respawn-exec-binary-on-disk branch from 87c45da to aad798d Compare October 20, 2026 11:45
@tchaikov

Copy link
Copy Markdown
Contributor Author

changelog

  • print the correct execv path in logging messages.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath10-testing-20261027.070130-main.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@tchaikov
tchaikov merged commit fd47998 into ceph:main Nov 5, 2026
16 of 17 checks passed
@tchaikov
tchaikov deleted the wip-respawn-exec-binary-on-disk branch November 5, 2026 08:57
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.

3 participants