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

Context Propagation issue #35842

Open
brice-laurencin opened this issue Sep 11, 2023 · 5 comments
Open

Context Propagation issue #35842

brice-laurencin opened this issue Sep 11, 2023 · 5 comments

Comments

@brice-laurencin
Copy link

Describe the bug

Trying the handle a collection from with parallelStream, calling a rest microprofile service ends up failing with java.util.ServiceConfigurationError: org.eclipse.microprofile.context.spi.ThreadContextProvider: io.smallrye.context.jta.context.propagation.JtaContextProvider not a subtype

Expected behavior

Parallel processing works

Actual behavior

fails with java.util.ServiceConfigurationError: org.eclipse.microprofile.context.spi.ThreadContextProvider: io.smallrye.context.jta.context.propagation.JtaContextProvider not a subtype after a few calls

How to Reproduce?

run tests from https://github.com/brice-laurencin/quarkus-context-propagation-issue

Output of uname -a or ver

Linux brice-work 6.2.0-32-generic #32-Ubuntu SMP PREEMPT_DYNAMIC Mon Aug 14 10:03:50 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)

GraalVM version (if different from Java)

n/a

Quarkus version or git rev

3.2.2.Final

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

------------------------------------------------------------ Gradle 8.1.1 ------------------------------------------------------------ Build time: 2023-04-21 12:31:26 UTC Revision: 1cf537a851c635c364a4214885f8b9798051175b Kotlin: 1.8.10 Groovy: 3.0.15 Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 JVM: 17.0.7 (Eclipse Adoptium 17.0.7+7) OS: Linux 6.2.0-32-generic amd64

Additional information

It kind of works when there is no JPA/Hibernate in the project. I had to add the actual DB to reproduce the issue I faced with my actual project.

@quarkus-bot
Copy link

quarkus-bot bot commented Sep 11, 2023

/cc @FroMage (context-propagation), @evanchooly (kotlin), @geoand (kotlin), @manovotn (context-propagation)

@The-Funk
Copy link

@brice-laurencin This same issue has been mentioned on stack overflow before. I think the reason context couldn't be propagated was because by nature parallelstream runs operations on the JVM's default ForkJoinPool of threads, which are not managed by Quarkus but the JVM itself.

@manovotn
Copy link
Contributor

@brice-laurencin This same issue has been mentioned on stack overflow before. I think the reason context couldn't be propagated was because by nature parallelstream runs operations on the JVM's default ForkJoinPool of threads, which are not managed by Quarkus but the JVM itself.

If that's the case then you are correct. The default ForkJoinPool cannot propagate contexts.

@brice-laurencin
Copy link
Author

Thanks! I'll test that.

@FroMage
Copy link
Member

FroMage commented Oct 24, 2023

Well, what people said here is true. But the symptom here is that there's a ClassLoader issue, leading to two instances of the class ThreadContextProvider to be loaded and incompatible. Now, perhaps it's a side-effect of the usage of parallelStream, but it's a bit weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants