Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite task wakeup after an h2 connection being shutdown #25

Open
bdbai opened this issue Jan 17, 2025 · 4 comments
Open

Infinite task wakeup after an h2 connection being shutdown #25

bdbai opened this issue Jan 17, 2025 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@bdbai
Copy link

bdbai commented Jan 17, 2025

Code to reproduce:

use compio::time::sleep;
use cyper::Client;
use http::Version;
use std::time::Duration;

#[compio::main]
async fn main() {
    let client = Client::new();
    println!("Send request 1");
    let response = client
        .get("https://example.com/")
        .unwrap()
        .version(Version::HTTP_2)
        .send()
        .await
        .unwrap();
    println!("Request 1 done, sleeping");
    sleep(Duration::from_secs(180)).await;
    println!("Send request 2");
    client
        .get("https://example.com/")
        .unwrap()
        .version(Version::HTTP_2)
        .send()
        .await
        .unwrap();
    println!("Now check your CPU usage");
    loop {
        sleep(Duration::from_secs(600)).await;
    }
}

Debugger shows that the task is being woken up unconditionally in h2's Connection::poll without any scheduling. Initial investigation might indicate the following issues:

  • The shutdown op in cyper (or compio) never finishes in this scenario, and/or
  • The h2 crate never considers a runtime where shutdown does not return Poll::Ready immediately, leading to a flawed poll implementation.
@Berrysoft
Copy link
Member

Has the issue been fixed?

@bdbai
Copy link
Author

bdbai commented Jan 23, 2025

h2 has fixed the infinite waking up in hyperium/h2#834, but the issue of connections not shutting down properly seems still persist.

Sharing some logs when debugging my bot program with h2=trace here: https://pastebin.com/43Npck46. There are 16 connection.state transitions, where 4 of them are Closing while all the remaining are Open. By right the Closing states should be followed by Closed shortly after poll_shutdown being done.

@bdbai
Copy link
Author

bdbai commented Feb 4, 2025

Now that h2 has fixed this: hyperium/h2#836, I guess we only need to wait for a new h2 release and bump our dependency version requirement (maybe in compio-io?).

@Berrysoft
Copy link
Member

Just cargo update, maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants