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

Rocket App Hangs #2729

Closed
4 tasks done
danbugs opened this issue Feb 18, 2024 · 5 comments
Closed
4 tasks done

Rocket App Hangs #2729

danbugs opened this issue Feb 18, 2024 · 5 comments
Labels
triage A bug report being investigated

Comments

@danbugs
Copy link

danbugs commented Feb 18, 2024

Rocket Version

0.5.0

Operating System

debian:bookworm-slim

Rust Toolchain Version

rustc 1.76.0 (07dca489a 2024-02-04)

What happened?

As mentioned, I've got my application deployed on a debian:bookworm-slim image. It was built on rustc 1.76.0 (07dca489a 2024-02-04).

I can make a couple of requests to it (/), but, eventually, like the title says, it hangs - for even as long as 5 minutes. Also, running Apache's benchmarking on it times out.

I attemped running strace on it, and I see this:

# strace -p 1
strace: Process 1 attached
futex(0x55a3ad62f0, FUTEX_WAIT_BITSET_PRIVATE, 2, NULL, FUTEX_BITSET_MATCH_ANY

Going from the interpretation of this post (that has the same issue as me), it's hanging on that futex - not really sure what to do about it.

Test Case

I did not manage to replicate this behaviour locally on my Windows machine. That said, my code is open source: https://github.com/danbugs/smithereens/blob/main/backend/src/main.rs

Log Output

As per above, I suppose this is non-applicable, but I am happy to attempt any fixes on my end as needed.

Additional Context

No response

System Checks

  • My bug report relates to functionality.
  • I have tested against the latest Rocket release or a recent git commit.
  • I have tested against the latest stable rustc toolchain.
  • I was unable to find this issue previously reported.
@danbugs danbugs added the triage A bug report being investigated label Feb 18, 2024
@SergioBenitez
Copy link
Member

There is a known issue with tokio that can cause this under certain conditions. Please see #2239. Does this sound like your problem?

@danbugs
Copy link
Author

danbugs commented Feb 18, 2024

I don't think this is the same issue, because my app hangs even on a simple "Hello, World!" return, and my route is as simple as:

#[get("/")]
fn index() -> &'static str {
    "Hello, world!"
}

Here's a video demo:
video-demo

@danbugs
Copy link
Author

danbugs commented Feb 18, 2024

Huh, never mind - I think this was actually not Rocket's fault. For context, I had my backend deployed on a Kubernetes cluster of Raspberry Pis and was accessing the backend through a NodePort service. I noticed that if I exec into the pod and curled it... It would never hang! So, to experiment, I tried swapping the NodePort for a LoadBalancer, and that did it 😅

This must be a problem w/ K3S's implementation of NodePorts. I'm closing the issue - thanks for the support👍

@danbugs danbugs closed this as completed Feb 18, 2024
@SergioBenitez
Copy link
Member

SergioBenitez commented Feb 18, 2024

Looking at your source code, this does seem to also be an instance of that, you're just not hitting it yet. You're using diesel, the synchronous version, in an asynchronous context. This will block. You simply cannot mix sync and async code, especially when there's I/O. For diesel, you must use diesel_async. Note that this isn't Rocket specific - this is the case for any async Rust application.

@danbugs
Copy link
Author

danbugs commented Feb 19, 2024

I don't think it should block when hitting my "Hello, World!" route though, no? Regardless, if the problem comes back, I'll make sure to change that. I appreciate your comment :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage A bug report being investigated
Projects
None yet
Development

No branches or pull requests

2 participants