Skip to content

Stop OSD frontends from outliving a killed daemon - #926

Open
KitsuneKode wants to merge 1 commit into
peteonrails:devfrom
KitsuneKode:fix/osd-outlives-daemon
Open

KitsuneKode wants to merge 1 commit into
peteonrails:devfrom
KitsuneKode:fix/osd-outlives-daemon

Conversation

@KitsuneKode

Copy link
Copy Markdown

Description

The OSD supervisor relied on kill_on_drop, which only fires when the supervisor task is dropped during an orderly shutdown, so a killed or crashed daemon left its OSD running and the next daemon drew a second one.

On Linux, the child now gets PR_SET_PDEATHSIG (SIGTERM) before exec, so the kernel stops it when the daemon dies, however it dies. The setting carries through the dispatcher's exec into the frontend. A getppid() check covers a daemon that died between fork and prctl. Other platforms are unchanged.

Related Issue

Fixes #922

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Testing

  • I have tested these changes locally: kill -9 on the daemon takes its qs down with it, and after systemd restarts the daemon there is exactly one qs, parented to the new daemon
  • I have run cargo test and all tests pass
  • I have run cargo clippy -- -D warnings with no warnings, apart from the clippy::double_must_use lint that current stable also reports on dev
  • I have run cargo fmt

Documentation

  • I have updated documentation as needed
  • No documentation changes are needed

Pre-merge checklist

  • This PR targets the dev branch (not main)
  • Wait for ci-success to pass before marking Ready for Review (draft mode is encouraged while CI is red)

Additional Notes

#879 also edits src/osd/supervisor.rs (the binary lookup); the two changes are in different functions.

The supervisor relied on kill_on_drop, which only fires when the
supervisor task is dropped during an orderly shutdown. A daemon that was
killed or crashed left its `qs` child running, re-parented to init and
still drawing a pill; the next daemon then drew a second one on top. Four
such orphans had piled up on one machine in an afternoon of testing.

On Linux, have the kernel deliver SIGTERM to the child when the daemon
dies (PR_SET_PDEATHSIG, set before exec, so it carries through the
dispatcher's exec into the frontend), with the usual getppid() check for
a daemon that died between fork and prctl.
@KitsuneKode
KitsuneKode force-pushed the fix/osd-outlives-daemon branch from a5402d1 to 2ba786a Compare November 24, 2026 10:53
@KitsuneKode
KitsuneKode marked this pull request as ready for review November 24, 2026 10:53
@KitsuneKode

KitsuneKode commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Rebased onto current dev; the conflict was only the surrounding supervisor code. fmt, all three clippy jobs and cargo test pass. dev's supervisor still relies on kill_on_drop alone, so the fix for #922 still applies.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OSD frontend outlives a killed or crashed daemon, so pills stack up

1 participant