Repository navigation
Shutdown: document what a silent conn and a head in the kernel get, per engine, and pin it (Refs #1208) - #1220
Merged
Merged
Conversation
…rnel, per engine (#1208) Refs #1208. Characterization tests: shape A (a conn that sent nothing) and shape B (a request head in the kernel, unread) on std, epoll, io_uring and adaptive, with the cells tagged as in the issue's table. The doc test is RED: the Shutdown godoc still says a silent conn is answered close when its first request is, and says nothing of the head in the kernel.
…nel get, per engine (#1208) Refs #1208. The Shutdown godoc said a conn that has sent nothing is answered close when its first request is; no engine does. It now lists what each state of a conn gets when Shutdown begins (idle, in progress, head in the kernel, silent), per engine, as measured by the tests of the previous commit. README and the two native gate comments say the same; the #1207 test comment no longer calls the native side unverified.
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…; parametrize requireDoc's tag (#1208) Refs #1208. New cells: A-accepted-draining and A-deferred-draining (a response going out on every worker: epoll closes at once, io_uring serves on for 250 ms and answers a first request), B-hold-other (the loop is held in another conn's OnConnect: epoll answers, io_uring drops), B-accept-hold-draining (io_uring answers when its worker has a response going out). requireDoc takes the issue tag for its failures. The doc test now wants the corrected godoc (RED here).
…xis of a head in the kernel (#1208) Refs #1208. Review r2 of #1220: an io_uring worker that has a response going out serves on for the first 250 ms of its send drain, so its idle and silent conns are closed at 250 ms and a first request before then is answered (also for a conn TCP_DEFER_ACCEPT holds back); a head in the kernel is answered on io_uring only while the worker is in its drain, a worker with nothing to send exits at once (an OnConnect callback is one way to the window, not the axis); std's reset needs unread body bytes (2 KiB gives a FIN). 'Measured on every engine' becomes what was measured. README and the two native gate comments say the same.
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.
Refs #1208
Per the maintainer's decision (2026-11-01): document both shapes, fix the
Shutdowngodoc, do not change std, add tests that pin the per-engine behaviour. No engine code changes here. The one real engine gap this found (io_uring, below) is fixed in #1224, stacked on this PR.Revised after review r2 (Opus): three claims of the first version were false on io_uring and are corrected; the removed sentence ("a conn that has sent nothing is answered close when its first request is") is not restored (it is false on epoll, std, and on an io_uring worker with nothing to send).
Verified table (docker arm64,
--cpus 2, golang:1.27.3, kernel 7.0.12-linuxkit, io_uring tier high; one tier and one arch only)"Sends pending" = every worker has a response going out (16 clients that do not read an 8 MiB response), i.e. a server under load when
Shutdowncomes.ShutdownbeginsShutdownreturned at 5.3 to 6.3 sOnConnect(24 conns it was reading)OnConnectheld)Mechanism of the io_uring "dropped" cells (review MAJOR-3, confirmed): a worker with no send pending and no parsed request exits on its first look at the shutdown, and
h1RequestInProgressdoes not look at the kernel (epoll's twin does).OnConnectwas never the axis. Fixed in #1224; after it the io_uring column reads answered in both dropped cells, and this PR's cells and godoc line flip there.Changes
a768c9a(tests):test/server/shutdown_conn_shapes_1208_linux_test.goandshutdown_doc_1208_test.go(a godoc test in the style ofdoc_limits_891_test.go; RED on main, because the godoc says the false thing).7d75a50(docs):Server.Shutdowngodoc, README, the two native gate comments, the test: the shutdown gate e2e waits until the engine has read the upload's head (Refs #1166) #1207 test comment.a12256e(tests, r2): cellsA-accepted-draining,A-deferred-draining(io_uring),B-hold-other,B-accept-hold-draining, andrequireDoctakes the issue tag (the new doc test prints Shutdown: a conn that sent nothing is not answered, and a request head already in the kernel is reset on std but answered on epoll; the godoc says otherwise #1208, not v1.6.0 polish: documentation #891). The doc test wants the corrected godoc and is RED on this commit alone.8a22618(docs, r2): godoc bullets 1, 3 and 4, README, the io_uring gate comment, the test: the shutdown gate e2e waits until the engine has read the upload's head (Refs #1166) #1207 test comment, to the table above: the io_uring send-drain window, the deferred conn, "reset only for unread body bytes", and "measured on arm64, 2 CPUs, kernel 7.0, io_uring high tier" instead of "on every engine".4429b9d(flake fix):A-deferred-drainingis io_uring only. On epoll, a loop busy sending closes its listener a few ms late and a first request that arrives before is answered, not reset (1 failure in 20 runs, found by my own loaded run); the godoc says so."The shutdown has begun" is observed, never slept for, except where noted in the cells: an idle conn's FIN (natives), the listener's refusal (std). A cell in which every conn lands on one loop (p = 2^-23) fails rather than skips, since an unlisted skip fails CI's tally. The send-pending state is read from
/proc/net/tcp(the server-side send queue of each staller is non-empty), not slept for.Cost: the
_1208_set takes about 2.9 s plain and 4.6 to 5.0 s under-racein the docker box (2 CPUs, 40 cells in parallel; the draining cells hold 16 x 8 MiB responses each), about 2 s more than the first version. Flake check on the final head: plain x20 and-racex20 with two busy loops: 720 PASS, 0 FAIL, 0 SKIP each. golangci-lint v2.14 (CI's pin, GOOS=linux, whole root module): 0 issues.For the issue thread (not written by me)
Shutdownbegins is answered on epoll, and on io_uring while its worker has a response going out or a request in progress when it sees the shutdown (a worker with neither exited at once and closed such a conn without an answer: fixed in iouring: a worker with nothing to send answers a request already in the kernel before it exits (Refs #1166 #1208) #1224); on std (net/http) it is dropped, GET with a FIN and a request with unread body bytes with a reset, because net/http checksshuttingDown()right afterreadRequest(server.go:2080, Go 1.27.3). The epoll: shutdown closes the idle HTTP/1 conns of a loop with no HTTP/2 conn before its send drain waits (v1.6.0, Refs #885 #1104) #1163 review's 'std answers it' holds only for a head std parsed beforeShutdown."Config.ReadHeaderTimeoutclosing a silent conn on std before the 5 s rule (the godoc does not claim it).Sentences for the docs repo (not in this PR; match the godoc as of #1224 for the head-in-the-kernel line)
Shutdownbegins. A request in progress is read on and answered, withConnection: close, on every engine. An idle keep-alive connection is closed at once by std and epoll, and by an io_uring worker with no response going out; an io_uring worker that has one serves on for the first 250 ms of its send drain, closes its idle connections at 250 ms, and answers, withConnection: close, a request one of them sends before then."Connection: close, on epoll and adaptive, and on io_uring (from iouring: a worker with nothing to send answers a request already in the kernel before it exits (Refs #1166 #1208) #1224; before, only while its worker had a response going out or a request in progress); std (net/http) drops it: the connection is closed without an answer, and reset if body bytes are still unread (a body of 2 KiB or less is read with the head and the close is a FIN)."DisableDeferAccept): thereShutdownneither closes it nor lets a request through (the first request gets a reset). An io_uring worker that has a response going out keeps accepting for its first 250 ms and answers a first request in that window, held back or not. std keeps the connection until its first request is read (and dropped) or net/http closes it at five seconds, so a client that connects and says nothing can holdShutdownon std for about five seconds, within theShutdowncontext."Shutdownbegan ends its connection; the budget is theShutdowncontext (andShutdownTimeoutfor a cancel ofStartWithContext).