caddyhttp: wait for servers from previous configs on exit - #8009
Open
dunglas wants to merge 1 commit into
Open
Conversation
Track pending HTTP server shutdowns across configuration reloads so termination waits for responses still served by an older configuration. Bound that wait by the terminating app's grace period and retain each reload's grace context until its servers finish shutting down. Cover HTTP/1.1, HTTP/2, and finite termination grace periods with regression tests.
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.
After a configuration reload, a long-lived response can remain on an older HTTP server. A subsequent process termination waits only for the current HTTP app's servers, so Caddy can exit in the middle of that older response. This surfaced with Mercure SSE connections while reviewing dunglas/mercure#1365 and also reproduces without that change.
Track pending server shutdowns across HTTP app instances and wait for them during termination, bounded by the terminating configuration's grace period. Reloads still return without waiting for active responses. Keep each reloaded app's grace-period context alive until its shutdown finishes, instead of cancelling it as soon as the nonblocking stop returns.
Assistance Disclosure
Codex assisted with diagnosis, implementation, and regression tests. The checks and integration reproduction below were run against the resulting code.
Validation
go test -race -short ./...,go build ./...,golangci-lint run --timeout 10m,go mod tidy -diff, and gopls checks on the changed files.