Repository navigation
fix(server): bound the HTTP graceful shutdown with a deadline - #439
Merged
Merged
Conversation
axum's graceful shutdown waits for every connection with a request in progress, and hyper's waits for an unfinished request head to complete. A half-sent request therefore held the process after SIGTERM until the peer closed it, and only the supervisor's stop timeout ended it, skipping the OTLP flush (plusky#435). The serve now has two seconds from the signal to drain its connections; past that the serve future is dropped and the OTLP flush below still runs. A row in binary_shutdown.rs holds a half-sent request across SIGTERM and proves the flush ran: the deadline warn is logged at the deadline and only the shutdown flush can deliver it before the process exits.
Contributor
Author
|
@plusky ready for review — the fix plus the regression test, full gate green. |
plusky
approved these changes
Nov 20, 2026
plusky
left a comment
Owner
There was a problem hiding this comment.
Approve — aggregated OCR + adversarial/security review (single review as requested).
OCR (native, range 7bab7fc..fefcfae): 0 findings, both files reviewed.
Adversarial + security, all verified locally:
- Fail-before proven: with the fix reverted (test kept), the new row fails exactly as described — the process stays up past the 5 s exit bound. With the fix it passes in ~2.3 s. The test pins the bug, not the implementation.
- Deadline arming is correct: the oneshot fires only inside the post-signal callback, and the serve cannot resolve before the signal (it only completes after graceful drain), so the 2 s bound cannot arm early;
let _ = send()tolerates the already-resolved case, and a pre-signal serve error keeps the pre-existing?path. - Audit durability strictly improves: dropping the serve past the deadline abandons stuck connections, but the OTLP shutdown flush below still runs — proven by the test (the warn is delivered to the mock collector). The alternative was hanging past the supervisor timeout into SIGKILL with no flush at all.
- No secret in the new surface: the warn is static text plus a
Duration; the OTLP endpoint env override lives in test-only harness code after the ambient scrub. - DESIGN stays accurate: the HTTP-serving note (shutdown cancels
ct, #114) and the shutdown test rows are unchanged in meaning; no stamped claim contradicts the bound, so no DESIGN update needed. - Helper refactor is behavior-preserving:
spawn_with_io_envonly threads extra env through the existing spawn path; existing callers pass&[].
All 19 CI checks green on the head. Merging.
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.
Fixes #435.
A half-sent HTTP request held the process after SIGTERM: axum's graceful shutdown waits for in-flight connections, and hyper's waits for an unfinished request head. The serve now has two seconds from the signal to drain its connections; past that the serve future is dropped and the OTLP flush below still runs.
A row in binary_shutdown.rs holds a half-sent request across SIGTERM and proves the flush ran: the deadline warn is logged at the deadline and only the shutdown flush can deliver it before the process exits. The row fails without the fix (the process stays up past the 5 s exit bound) and passes with it in 2.8 s, 5/5 runs. Full gate green (fmt, clippy, clippy --features gen, doc, cargo test --workspace, cargo deny).