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.

Vertx context doesn't get propagated with microprofile faultolerance

See original GitHub issue

Describe the bug

When using the microprofile faultolerance @Retry annotation, the Vert.x context doesn’t get propagated to the retries. From a quick debugging session it looks to be because the retry annotation uses the microprofile executor system which does not included context propagation for Vert.x

The problem can be worked around with https://github.com/quarkusio/quarkus/issues/25818#issuecomment-1138934118 so the issue is probably related to that.

Expected behavior

Context (such as MDC) is available during method retry

Actual behavior

Context is empty during method retry

How to Reproduce?

Repro is available here: https://github.com/sparnord1337/quarkus-verx-cp-repro. The test of the sample has been adjusted such that it would pass if the functionality worked so ./mvnw test will repro the issue.

Output of uname -a or ver

Linux SNBWS0034 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 GNU/Linux

Output of java -version

openjdk version “17.0.5” 2022-10-18

GraalVM version (if different from Java)

No response

Quarkus version or git rev

>2.9.3.Final

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

No response

Additional information

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sparnord1337commented, Nov 11, 2022

I’ve checked 2.10 and 2.13.3.Final. I’ll give 2.14 a shot.

0reactions
Ladicekcommented, Nov 11, 2022

Okay, so that makes a huge difference. MP Fault Tolerance @Asynchronous means “run this method on another thread”, unconditionally. The only thing SmallRye Fault Tolerance can do is provide support for MP Context Propagation for @Asynchronous methods – which it does.

Now, I don’t know if the Vert.x Context is thread-safe – if it is, the solution from https://github.com/quarkusio/quarkus/issues/25818#issuecomment-1138934118 is probably the right thing to do. If the Vert.x context is not thread safe, then propagating it is a bad idea in any case.

However, there’s a different angle to this. MP Fault Tolerance @Asynchronous is designed for offloading blocking methods to other threads. If your @Asynchronous method is in fact non-blocking, it can be executed on the original thread, which is presumably the Vert.x event loop thread. SmallRye Fault Tolerance supports that too – in addition to @Asynchronous, add @NonBlocking (starting with SmallRye Fault Tolerance 5.6.0, which will be in Quarkus 2.15, @AsynchronousNonBlocking will be preferred).

Read more comments on GitHub >

github_iconTop Results From Across the Web

SmallRye Fault Tolerance - Quarkus
MicroProfile Context Propagation is integrated with Fault Tolerance, so existing contexts are automatically propagated to your asynchronous methods. This also ...
Read more >
Chapter 2. Understand Eclipse MicroProfile Red Hat JBoss ...
The Eclipse MicroProfile Fault Tolerance specification defines strategies to deal with errors inherent in distributed microservices.
Read more >
Bring Concurrency to MicroProfile - Google Groups
CDI built-in contexts (Request Context, Session, etc...) don't propagate. Even Application context doesn't : it is shared across application ...
Read more >
Fault Tolerance 4.0 - SmallRye
The MicroProfile Fault Tolerance specification also requires certain features that Hystrix intentionally doesn't provide; most importantly, the ability to ...
Read more >
Develop reactive microservices with Reactive Messaging
With MicroProfile Context Propagation, the thread context is ... Understand further how Fault Tolerance can help with asynchronous ...
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