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

   ### Motivation
   `PoolInterface.Logic` keeps requests the pool cannot take yet in an 
`ArrayDeque` of `RequestContext`s, each holding the promise that the caller of 
`Http().singleRequest` (or of a cached host connection pool flow) is waiting on.
   
   When the stage stops without having dispatched them — the pool flow failing 
or cancelling, or the materializer shutting down — `postStop` only failed 
`shutdownPromise`. Nothing else holds those queued contexts: they were never 
handed to a connection, so no response, no error and no retry through the pool 
master can ever reach them, and the callers' `Future[HttpResponse]`s stay 
uncompleted for the lifetime of the process.
   
   Note that this is only reachable on the abnormal stop paths: a requested 
shutdown waits for `remainingRequested` to reach `0`, which counts the queued 
requests too.
   
   ### Modification
   Drain the buffer in `postStop` and fail every queued response promise with 
the same `IllegalStateException` already used for the shutdown promise.
   
   ### Result
   A pool that stops unexpectedly fails the requests it never dispatched 
instead of leaving their callers waiting forever.
   
   ### Tests
   - New `PoolInterfaceSpec`: the interface stage is joined to probes, three 
requests are queued while the pool signals no demand, and the pool flow is then 
completed. The test asserts all three promises fail. Reverting only the 
`postStop` change makes it fail — the promises are never completed.
   - `sbt "http-core/testOnly 
org.apache.pekko.http.impl.engine.client.PoolInterfaceSpec"` — pass (1 test).
   - `sbt "http-core/mimaReportBinaryIssues"` — pass.
   - `scalafmt --mode diff-ref=upstream/main --test` — pass.
   
   ### References
   None — found while auditing `src/main` for resource leaks.
   


-- 
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