Repository navigation
Description
"h2 RunAsync begun on the thread pool (http2): an upload read and echoed from the pool arrives whole, served on the reactor" (OffReactorH2FixTests.cs:71-73) failed in 2 of the 24 full E2E logs kept from today's #581-#592 batch, all on trees with #593, and once more in a review run. It passed 170 rounds run alone, and its nghttp2 twin passed in every run.
- Local run on kestrel: a connection whose reactor stops ends in Kestrel and finishes its dispose, instead of waiting forever on pipe continuations the reactor dropped (#583) #600's branch, which changes only Kestrel:
One or more errors occurred. (The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'FRAME_SIZE_ERROR' (0x6). (HttpProtocolError)) - kestrel: a connection whose reactor stops ends in Kestrel and finishes its dispose, instead of waiting forever on pipe continuations the reactor dropped (#583) #600's CI, ubuntu-latest, attempt 1:
the transport was only called from its reactor (3 calls from elsewhere) - A review run on http2: an answer waiting on the client's credit has its unread upload credited, so a client that uploads everything first gets it (#588) #604's tree:
Error while copying content to a stream(no log kept)
Likely cause (a hypothesis, from reading). #593 turned the preface's await FlushAsync() into await FlushPassAsync(), which starts the pump detached and returns at once (Http2Connection.cs:194-196, Http2Connection.Write.cs:95-113). The old await parked the loop on the SETTINGS flush, which a TCP pipe completes on the reactor (TcpConnectionPipeWriter.cs:76-78), so the first read was always issued from there; the nghttp2 twin still works that way (Nghttp2Connection.RunBuffered.cs:48-56). A RunAsync begun on the pool now issues its first read from the pool:
- That read completes synchronously if the client's preface is already queued (
TcpConnectionPipeReader.cs:105-123,TcpConnection.Read.cs:86-91), and a client need not wait for the server's (RFC 9113 3.4).Reactor.Currentis null off the reactor (Reactor.Post.cs:33-37), so_reactorstays null,ReactorSwitch(null)does not hop (ReactorSwitch.cs:27), and the pass runs on the pool (Http2Connection.cs:198-202). - With
_reactornull,OffReactoris false (Http2Connection.cs:94), so the handler'sWriteHeaders, flushes and body reads run inline on its own pool thread (Http2ResponseWriter.cs:84-90,:270-283,Http2BodyReader.cs:63-68). - Meanwhile the SETTINGS pump resumes on the reactor when its flush completes (
Http2Connection.Write.cs:131-132).
The class is reactor-only (Http2Connection.cs:28). Stage, the queue and the pump share _flushing, _queued and the pipe writer with no lock, the pump empties the queue by resetting _queuedUsed, and a frame's header and payload are separate Stage calls (Http2Connection.Write.cs:47-74, :153-155, :409-417). Two threads staging at once can put another frame between a header and its payload, or drop queued bytes; the client then reads echoed upload bytes as a frame header, whose length is far past its 16,384 limit: FRAME_SIZE_ERROR. The test's transport counts only calls made after a read completed on the reactor (OffReactorH2FixTests.cs:328-342), so a first pass on the pool goes unseen, and handler calls still running inline after that are the "calls from elsewhere". On the reactor alone the read-during-flush path keeps stage order; I found no single-threaded way for it to tear a frame.
Fix. Confirm it first: hold RunAsync on the pool until the client's preface has arrived (a short delay before serve in StartH2, OffReactorH2FixTests.cs:234-244), so the first read completes there. If the test then fails, let no pass run while _reactor is null, for example by awaiting the preface flush while the reactor is unknown, as before #593 and as the nghttp2 twin does.
Seen by #583's implementer, locally and in #600's CI, and by #604's reviewer. The cause is from reading at main 19aec5c; not reproduced.
Activity
http2: a RunAsync begun off the reactor reads only once its SETTINGS …