Vertx context doesn't get propagated with microprofile faultolerance
See original GitHub issueDescribe 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:
- Created 10 months ago
- Comments:8 (2 by maintainers)
I’ve checked 2.10 and 2.13.3.Final. I’ll give 2.14 a shot.
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).