rwf2 / Rocket

A web framework for Rust.

Home Page:https://rocket.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rocket App Hangs

danbugs opened this issue · comments

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.

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

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

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👍

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.

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 :)