Repository navigation
feat(server): add Connection::shutdown_notice - #1001
Open
derekargueta wants to merge 1 commit into
Open
derekargueta wants to merge 1 commit into
derekargueta wants to merge 1 commit into
Conversation
Sends the first GOAWAY of a graceful shutdown (last stream ID 2^31-1) and a PING, without the final GOAWAY, which waits for `graceful_shutdown`. If the PING was acknowledged by then, the final GOAWAY goes at once; otherwise it goes when the acknowledgement comes, as before. This lets servers warn clients of a shutdown when they start draining and finish it later, as Envoy does with `drain_timeout`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
graceful_shutdownsends both GOAWAYs that RFC 9113 §6.8 describes:A server therefore can't warn clients that a shutdown is coming and finish it later. That split is what proxies do when they drain. For example, Envoy sends the first GOAWAY as soon as a connection starts draining. Clients can then move new requests elsewhere, while requests already in flight are still accepted. Envoy sends the final GOAWAY only once its
drain_timeouthas passed.This PR adds
server::Connection::shutdown_notice(), which:NO_ERROR) and the shutdown PING;graceful_shutdown(), which sends it:graceful_shutdowndoes today;graceful_shutdown()is called;When
shutdown_noticeisn't used,graceful_shutdownbehaves exactly as before.Implementation:
GoAwaytracks whether the notice isSentorAcked. While a notice is outstanding, the shutdown PING's acknowledgement records that the client has seen it instead of sending the final GOAWAY.Tests: two new tests in
tests/h2-tests/tests/server.rs:shutdown_notice_then_graceful_shutdown: the notice and its PING are sent, and the connection keeps taking streams after the acknowledgement. Thengraceful_shutdownsendsGOAWAY(3)without a second PING.graceful_shutdown_before_shutdown_notice_acked: repeatedshutdown_noticeandgraceful_shutdowncalls send one GOAWAY and one PING. The final GOAWAY follows the acknowledgement, and a stream that was in flight still completes.Related: hyperium/hyper#3961 (a different shutdown sequence, with the same goal of telling clients early).
🤖 Generated with Claude Code