-
Notifications
You must be signed in to change notification settings - Fork 600
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
Concurrency issues on the cached Jsonb instance #26881
Comments
In 23.0.0.10, Open Liberty updated to Yasson 3.0.3 and Parsson 1.1.4. The update to the Yasson 3.0.3 caused similar issues to what are reported here and related to a defect in the Parsson code that required the update to Parsson. That problem was related to when things were closed in Parsson. The Jsonb class javadoc states below.
In the scenario that you are attempting, do you ever close the Jsonb object either explicitly or with a try resources block? |
No, in our case close() is not being called. |
So here is a timeline from this yasson/parsson compatibility situation:
Did you catch the issues? (&) Yasson also placed the close in the finally block (using try-with-resources) which means it is closing streams even when there is a failure further failing to implement the JSONB API What about Parsson? Next Steps: try (var ioStream = createIoStream()) {
jsonb.toJson(object, ioStream);
} @imgea |
We aren't using any streams or reader/writers. But digging into it more I've found that this concurrency errors happened only when we had a library introducing yasson library to our build path (as both compile & runtime artifact). |
Here you can find a small repo that reproduces the issue: https://github.com/imgea/ol-jsonb-test/ |
@imgea thanks for providing a reproducer for this. It looks like yasson/parsson are being packaged with the application and the versions that are being packaged together are incompatible yasson-3.0.3 / parsson-1.1.0 Your applications do not need to have yasson/parsson dependencies, those are provided for you by Liberty though our features. You should slim down your application by using the Therefore your original project configuration: would become: dependencies {
// Application Dependencies
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'ch.qos.logback:logback-classic:1.4.11'
implementation 'org.mongodb:bson:4.8.0'
implementation 'com.google.guava:guava:31.0.1-jre'
// Dependencies provided by Open Liberty
compileOnly 'org.eclipse.microprofile:microprofile:6.0'
compileOnly group: 'org.eclipse', name: 'yasson', version: '3.0.3'
} I would suggest checking your production application(s) and verify that any Microprofile/JakartaEE artifacts are not being packaged in with your applications. |
Yes indeed we've already fixed the library that introduced the yasson dependency. |
@KyleAure I'm experiencing this very problem after migrating to 23.0.0.10. However, removing "yasson" as a direct dependency of my project only lead me to an error:
|
My bad, I did not correctly interpret your suggestion at first. I got it working now with the following Maven configuration: <dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>3.0.3</version>
<scope>provided</scope><!-- The important bit. -->
</dependency> I'm still not sure and would like to understand why adding "provided" / "compileOnly" makes it work. Both with and without it, Yasson 3.0.3 shows up as a dependency, so what's different? |
When you say |
I guess my question is, if Open Liberty already comes with a valid JSON-B implementation, why do I need Yasson as an additional dependency? It feels redundant. |
You should not need that dependency at all. As mentioned in my earlier reply, you may have a unit test dependency in your maven project if you can run tests outside of an application server. If you do not have that requirement, then yes it can be removed. |
It took me a while to get to validate this, but I confirm I could indeed remove the dependency, and it was only the tests that would fail. In fact, |
Likely the reason your Hope that makes sense. |
Describe the bug
We have a cached static Jsonb instance used application wide and only with the latest release (23.0.0.10) we started running into concurrency issues with multiple threads executing fromJson & toJson methods.
For example, we can observe malformed json outputs as a result of toJson method.
Steps to Reproduce
Using a cached Jsonb application wide under high load
Expected behavior
The usage of the cached Jsonb instance's methods should be thread-safe as with the previous OL versions.
Diagnostic information:
Additional context
When we enable jsonbContainer-3.0 feature and reference yasson libraries (yasson-3.0.0.jar,..,yasson-3.0.3.jar) like the below server.xml config then we encounter no concurrency issues with the cached Jsonb instance.
The text was updated successfully, but these errors were encountered: