programatik29 / axum-server

High level server designed to be used with axum framework.
MIT License
177 stars 63 forks source link

graceful_shutdown doesn't shut down gracefully #114

Closed droundy closed 2 months ago

droundy commented 6 months ago

I'm seeing that there is always a single connection registered if the Watcher for a connection hasn't yet been dropped when graceful_shutdown is called (which is the point of graceful_shutdown!).

connection made, and so graceful_shutdown doesn't exit until the timeout happens.

I've reproduced this both with axum-server 0.6.0, and with the current master branch. I added prints to confirm which code branches are getting triggered. This is readily triggered by integration tests in my code (which I cannot share), which will uniformly fail if I don't insert a brief wait between when I receive a response and when I send a SIGINT to the process.

Specifically, I'm seeing that after the code reaches this line:

https://github.com/programatik29/axum-server/blob/master/src/server.rs#L207

the serve_future in the inner select! doesn't ever finish.

If I wait a millisecond before sending the SIGINT, then the connection is marked as completed and graceful shutdown exits cleanly. Except of course that this is the scenario where one wants to gracefully shut down.

droundy commented 6 months ago

I should probably add that this problem surfaced with the upgrade from axum-server 0.5.1 to axum-server 0.6.0, which happened at the same time as a move toaxum0.7.4, in case that helps.