shinseongsu commented on PR #743:
URL: 
https://github.com/apache/httpcomponents-core/pull/743#issuecomment-7207758856

   Hi @arturobernalg, nice work on this one 👍 I tried it against a raw-socket 
H2 client and the main case works: a request that shows up after the first 
GOAWAY gets served and the final GOAWAY comes back with `last=1`. On master the 
same request is just dropped (`last=0`).
   
   One thing I ran into: if the peer never answers the PING, the 
`pingAckTimeout` deadline doesn't seem to kick in. 
`gracefulShutdownDeadlineReached()` only runs from `onInput()` / `onOutput()`, 
so once the GOAWAY + PING are flushed, a silent peer never triggers another I/O 
event.
   
   Setup: server with `soTimeout=30s`, client finishes the preface/SETTINGS and 
then goes quiet.
   
   `initiateShutdown()` + `awaitShutdown(60s)`:
   ```
     +10ms  GOAWAY last=2147483647
     +11ms  PING
     +30030ms GOAWAY last=0      <- comes from onTimeout (soTimeout), not the 
5s probe
   ```
   
   `close(CloseMode.GRACEFUL)`:
   ```
     +10ms  GOAWAY last=2147483647
     +12ms  PING
     (no final GOAWAY, reactor force-closes the socket at 5005ms)
   ```
   
   With the default `IOReactorConfig` (`soTimeout=0`), I think the first case 
would only end when the caller's await runs out.
   
   <details>
   <summary>Full matrix (master / this PR / local tweak)</summary>
   
   | peer behaviour | master | PR | local tweak |
   |---|---|---|---|
   | ACKs the PING | final GOAWAY 10ms | 14ms | 35ms |
   | sends a request after GOAWAY(MAX) | request dropped, last=0 | served, 
last=1 | served, last=1 |
   | never ACKs, initiateShutdown/await | 10ms | 30030ms | 5007ms |
   | never ACKs, close(GRACEFUL) | 9ms | no final GOAWAY, closed at 5005ms | 
same as PR |
   
   </details>
   
   To check it, I tried a small local change: while the probe is pending, set 
the session socket timeout to `pingAckTimeout`. In `onTimeout()`, if we're 
still waiting on the probe, send the final GOAWAY and restore the old timeout. 
Otherwise it does the normal timeout handling. With that the silent case ends 
at ~5s with `GOAWAY last=0`, and the ACK / in-flight cases behave the same as 
before.
   
   ```java
   // executeShutdown(), server branch
   if (!pingAckTimeout.isDisabled()) {
       gracefulShutdownSavedSocketTimeout = ioSession.getSocketTimeout();
       ioSession.setSocketTimeout(pingAckTimeout);
   }
   
   // onTimeout()
   if (gracefulShutdownAwaitingPing) {
       completeGracefulShutdown();   // also restores the saved socket timeout
       requestSessionOutput();
       return;
   }
   ```
   
   But I noticed the tests check `setSocketTimeout` is never called 
(`testServerGracefulShutdownPreservesConfiguredSocketTimeout` and 3 others), so 
I guess you avoided touching the socket timeout on purpose 🤔 If so, maybe 
something like a `min(pingAckTimeout, configured timeout)` while the probe is 
pending, or another way to wake the session, would work. Happy to open a PR 
against your branch with the tweak + a test if that helps.
   
   There's also the `close(GRACEFUL)` case: the reactor gives up after 5s and 
`pingAckTimeout` is also 5s, so even with the tweak the final GOAWAY loses that 
race. Not sure that's worth handling here, just mentioning it.
   


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