hyperium / hyperium/hyper

Graceful shutdown never finishes

Open
#2,294 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.3k
Forks
1.8k
Avg merge
1d 22h
Merged PRs (30d)
14

Description

Hey, I have an endpoint that shutdown will never finish when the server get the following error or overloaded:
[2020-10-01][14:52:50][hyper::server::tcp][ERROR] accept error: Too many open files (os error 24)

let graceful = server.with_graceful_shutdown(async {
     rx.await.ok();
     // still it reaches this line
});

if let Err(e) = graceful.await {
    error!("error: {}, endpoint: {}", e, self.addr);
}
// but never reach this line when the server get `accept error / Too many open files`

I can also confirm that after the accept error and before the shutdown there are open connections left behind with state (using ss -t)

  • FIN-WAIT-1 0 2822 127.0.0.1:terabase 127.0.0.1:40830

  • LAST-ACK 0 1 127.0.0.1:40830 127.0.0.1:terabase

  • FIN-WAIT-1 0 2822 127.0.0.1:terabase 127.0.0.1:40830

And after sending shutdown signal some connections get dropped but still some active with ESTAB state

  • ESTAB 0 0 127.0.0.1:terabase 127.0.0.1:57234

Also something important to mention that my application handles all requests that are passed to handle function and using atomic I was able to verify that no active API call left behind, so probably the issue is from hyper side whenever the server get overloaded or accept error

Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the server.with_graceful_shutdown entry point and reproduce the accept error: Too many open files with lingering ESTAB or closing connections. Trace why graceful.await does not complete after the shutdown signal; done means shutdown finishes even when the accept loop encounters this error and connections remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.