pjfanning opened a new pull request, #1281:
URL: https://github.com/apache/pekko-http/pull/1281

   ### Motivation
   `IncomingStreamBuffer.shutdown()` fails the entity outlet and drops whatever 
is still buffered, but unlike the other discard paths (`onRstStreamFrame`, 
`onDownstreamFinish`, fixed in #1259) it never subtracted those bytes from 
`totalBufferedData`.
   
   One of its callers leaves the connection running: when a peer sends more 
data than the stream-level window allows, `onDataFrame` resets that single 
stream with `FLOW_CONTROL_ERROR` and the connection carries on. The bytes still 
buffered for the stream, plus the payload of the frame that is dropped without 
ever being buffered, keep counting as buffered for the lifetime of the 
connection.
   
   The connection-level flow controller only emits a `WINDOW_UPDATE` while 
`outstanding + buffered` stays below half of 
`incoming-connection-level-buffer-size`, so the leaked accounting permanently 
reduces the replenishment of the connection window — and once it reaches half 
the buffer size, stops it entirely, at which point every stream on that 
connection stalls.
   
   ### Modification
   Release the buffer in `IncomingStreamBuffer.shutdown()` through the existing 
`discardBuffer()`, and subtract the payload of the frame that trips the 
stream-level window check, since that frame is never buffered either.
   
   The other two `shutdown()` callers are GOAWAY paths where the connection is 
going away anyway, so the extra release is a no-op for them.
   
   ### Result
   Resetting a stream for a flow-control violation releases the 
connection-level window its data reserved, so the connection keeps being 
replenished and no longer stalls.
   
   ### Tests
   - `sbt "http2-tests/testOnly 
org.apache.pekko.http.impl.engine.http2.Http2ServerSpec"` — **Not run - 
environment failure**: `http2-tests / update` cannot resolve 
`io.github.summerwind:h2spec_darwin_amd64:2.6.0` (`h2spec_darwin_amd64.tar.gz 
not found under 
https://github.com/summerwind/h2spec/releases/download/v2.6.0/`), which blocks 
the whole module locally. Needs the CI run — that is why this is a draft.
   - New test `release connection-level flow control accounting when a 
stream-level window is exceeded` in `Http2ServerSpec`: a peer overruns the 
stream-level window with `incoming-connection-level-buffer-size` sized so the 
discarded frame is more than half of it, then the test asserts the connection 
window is handed back in full. Without the fix no `WINDOW_UPDATE` is emitted at 
all, so the expectation times out.
   - `scalafmt --mode diff-ref=upstream/main` — pass.
   - MiMa not run: internal `impl.engine.http2` change with no public API or 
binary shape impact.
   
   ### References
   Refs #1259 — same accounting leak on the remaining discard path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to