question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

First mail executed from Vertx's ordered blocking pool gets stuck

See original GitHub issue

Describe the bug

My application is trying to send emails from a thread in vertx’s blocking pool with ordered=true. The first mail sent from the application get’s stuck/times out when I use the reactive mailer directly with .await.atMost(…). The email is still sent (I get it) after the exception is raised.

I suspect that something in the SMTP connection handshake requires ordered execution, too, and the threads deadlock.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

first-mail.zip

Start this application in dev mode and then run curl localhost:8080/pooled?ordered=true -v -X POST. The request should complete with 204 but this appears in server log:

2022-10-03 14:10:09,101 INFO  [com.exa.GreetingResource] (executor-thread-0) About to send mail through pool, ordered=true
2022-10-03 14:10:09,102 INFO  [com.exa.GreetingResource] (vert.x-worker-thread-0) Sending mail...
2022-10-03 14:10:14,124 ERROR [com.exa.GreetingResource] (vert.x-worker-thread-0) Failed to send: io.smallrye.mutiny.TimeoutException
...

Note that the SMTP server used in this example requires you to execute it from within Red Hat internal network.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.12.3, also 2.13.0

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mkoubacommented, Oct 12, 2022

Why do you use the reactive mailer on a vertx worker thread? I mean it would make sense to use the imperative/blocking version on a worker thread and the reactive version on the even loop (an I/O thread), i.e. in a non-blocking resource or scheduler method.

Could you please provide a simple project that would reproduce this behavior?

0reactions
cescoffiercommented, Oct 17, 2022

The problem comes from the usage of ordered executeBlocking, which creates a Frankenstein monster in terms of the execution model (you are on an event loop, you switch to a worker, but you can’t go back to the event loop because of ordered=true) Either use the reactive mailer, and use Uni / Multi, or use the imperative mailer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vertx Http Webclient request hangs even though worker ...
It responds when worker thread is not blocked. I thought, If I block the worker thread, there are other worker threads from the...
Read more >
Troubleshooting the Performance of Vert.x Applications, Part III
Blocked thread checker. Vert.x comes with a built-in mechanism to detect delays on event loop and worker threads by checking the execution time ......
Read more >
Troubleshoot Dataflow errors - Google Cloud
Look for messages that indicate that the DoFn code is stuck or otherwise encountering issues. If no messages are present, the issue might...
Read more >
Smashing Vert.x core. Unless you've been living in a cave for…
RUNNABLE: Thread executing in JVM. WAITING: Waiting ad infinitum for some other thread to perform some action. BLOCKED: Waiting to get monitor ...
Read more >
An introduction to Vert.x, the fastest Java framework today
The problem is, this driver is blocking. And it's blocking at the socket level. A thread will always get stuck there until it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found