fix(graceful-upgrade): fix uninterruptible grace period and stale FD …#6
Merged
gabioprisan merged 1 commit intogcorefrom Apr 6, 2026
Merged
fix(graceful-upgrade): fix uninterruptible grace period and stale FD …#6gabioprisan merged 1 commit intogcorefrom
gabioprisan merged 1 commit intogcorefrom
Conversation
…accumulation Issue 1 — Uninterruptible grace period after SIGTERM/SIGQUIT: After main_loop consumed signal handlers via tokio::select!, a bare thread::sleep(grace_period) left the process unresponsive to further signals for up to 20 minutes. Replace with a 1-second polling loop that checks an AtomicBool set by a signal-watching task spawned on the still-running server_runtime. A second SIGTERM/SIGINT/SIGQUIT during the grace period now causes an early exit. Issue 2 — Stale inherited FDs accumulate across upgrade generations: serialize() dumped the entire Fds map, including ports removed from the current config. These zombie FDs were forwarded to every subsequent process generation, holding ports open indefinitely. Fix with a two-map design in Fds: inherited FDs from deserialize() live exclusively in inherited_pending until a listener claims them via add() or mark_used(). close_unused_inherited() drains inherited_pending, closing stale FDs before send_to_sock() on SIGQUIT. Drop provides a safety net. Also fix the non-NoSteal listen() path in l4.rs which never called mark_used(), causing active listener sockets to be closed by close_unused_inherited() on third-generation upgrades. Add integration tests: - server_phase_gracefulupgrade: SIGQUIT → full phase progression - server_phase_early_exit: second SIGTERM interrupts grace period
andraprs
approved these changes
Apr 6, 2026
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.
…accumulation
Issue 1 — Uninterruptible grace period after SIGTERM/SIGQUIT: After main_loop consumed signal handlers via tokio::select!, a bare thread::sleep(grace_period) left the process unresponsive to further signals for up to 20 minutes. Replace with a 1-second polling loop that checks an AtomicBool set by a signal-watching task spawned on the still-running server_runtime. A second SIGTERM/SIGINT/SIGQUIT during the grace period now causes an early exit.
Issue 2 — Stale inherited FDs accumulate across upgrade generations: serialize() dumped the entire Fds map, including ports removed from the current config. These zombie FDs were forwarded to every subsequent process generation, holding ports open indefinitely.
Fix with a two-map design in Fds: inherited FDs from deserialize() live exclusively in inherited_pending until a listener claims them via add() or mark_used(). close_unused_inherited() drains inherited_pending, closing stale FDs before send_to_sock() on SIGQUIT. Drop provides a safety net.
Also fix the non-NoSteal listen() path in l4.rs which never called mark_used(), causing active listener sockets to be closed by close_unused_inherited() on third-generation upgrades.
Add integration tests: