Repository navigation
fix(server): Use tokio::select when waiting for connection close/global graceful shutdown - #30
Conversation
|
Thanks for sending the PR. Some feedback to consider:
|
555de8d to
ccace6d
Compare
|
Appreciate it! 1, Signoff passes DCO now. |
The earlier pattern came as a result of the upgrade from Hyper 0.14 to Hyper 1.x. We were blocking on the global shutdown signal after each connection, causing the connection structs to stay allocated in memory. Over a flood of many connections (even after they close), this was causing significant memory leaks. Signed-off-by: Yadunandan Pillai <contact@mail.thesw4rm.com>
Signed-off-by: Yadunandan Pillai <contact@mail.thesw4rm.com>
Signed-off-by: Yadunandan Pillai <contact@mail.thesw4rm.com>
ccace6d to
8ce4f15
Compare
|
Hey @raykroeker . Looks like the issue reporter confirmed that linkerd/linkerd2#15684 is likely directly related to the fix (same reproduction steps). They're not comfortable building their own image. Do you think this PR is ready to merge, so they can confirm the fix on their end? |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yadunandan Pillai <contact@mail.thesw4rm.com>
|
@raykroeker bumping this one, if you've got the time! |
|
The PR LGTM but it needs a A nice-to-have would be a test for ensuring that shutdown closes in-flight connections gracefully. I don't think that path was tested prior to this change and it isn't strictly related but I'm calling it out because you did alter the shutdown path a little bit. Based on the observed behavior in linkerd/linkerd2#15684, this fix makes sense to me. There was never a mechanism for the parent task to exit when the spawned child task was done. |
| // tasks. Each one is dropped when its task completes. | ||
| server.abort(); | ||
| let _ = server.await; | ||
| tokio::time::timeout(std::time::Duration::from_secs(2), drain_tx.closed()) |
There was a problem hiding this comment.
is there anything special about using a two second timeout here?
There was a problem hiding this comment.
Not really. It shouldn't ever take more than a few hundred milliseconds to drain.
|
let's get @raykroeker's sign off as well. i'll poke today. thanks for waiting! |
Solves linkerd/linkerd2#15684
BUG
Connections were not being dropped from memory after being closed.
server_connwas waiting on a release shutdown signal. This was a regression likely caused by the hyper 0.14 to 1 bump in a95478aFIX
Switch back to a
tokio::selectpattern. Branch predictor is optimized to check the connection being closed first, before polling for a shutdown signal.Signed-off-by: Yadunandan Pillai contact@mail.thesw4rm.com