Open bmarwell opened 10 months ago
We from JobRunr have the same issue. We are using Yasson as an option to generate JSON from some objects and sometimes it generates invalid JSON - this is with really limited parallelism (about 2 simultaneous requests).
The invalid JSON:
[{"deleteSucceededJobsAfter":129600.000000000,"firstHeartbeat":"2024-01-16T08:38:09.971713Z","id":"6e836e6f-3bea-4dc8-9d90-804ce2d3f76c","lastHeartbeat":"2024-01-16T08:38:39.994807Z","name":"Ismailas-MacBook-Pro.local","permanent,{"type":"severe-jobrunr-exception"0000000,"pollIntervalInSeconds":15,"processAllocatedMemory":18048136,"processCpuLoad":0.0020519469633203924,"processFreeMemory":17161821048,"processMaxMemory":17179869184,"running":true,"systemCpuLoad":0.2227047146401985,"systemFreeMemory":20553973760,"systemTotalMemory":68719476736,"workerPoolSize":96}]
Notice the permanent where invalid json is generated. Below is the valid json:
[{"deleteSucceededJobsAfter":129600.000000000,"firstHeartbeat":"2024-01-16T08:38:09.971713Z","id":"6e836e6f-3bea-4dc8-9d90-804ce2d3f76c","lastHeartbeat":"2024-01-16T08:41:40.032196Z","name":"Ismailas-MacBook-Pro.local","permanentlyDeleteDeletedJobsAfter":259200.000000000,"pollIntervalInSeconds":15,"processAllocatedMemory":48091728,"processCpuLoad":4.15962064712972E-4,"processFreeMemory":17131777456,"processMaxMemory":17179869184,"running":true,"systemCpuLoad":0.17733182589033353,"systemFreeMemory":20528300032,"systemTotalMemory":68719476736,"workerPoolSize":96}]
@rdehuyss for me I found that I was actually writing to the same file twice. Switching to Apache Johnzon only fixed it because it was way faster. For me, this is closed. But I can leave it open for you.
@bmarwell : these were two different Strings (so not even files).
Hello @bmarwell and @rdehuyss , I have tried to reproduce this and no luck so far.
Would you please be so kind and try to verify, if this still happens with the latest release?
No I was not able to reproduce it. Maybe it was overlapping writing to the same files after all?
Describe the bug
When writing JSON files in parallel with multiple threads (>>100), JSON files are very likely (>80%) to get corrupted like so:
Sometimes even data from other files is included randomly, again invalidating the JSON file. This does not happen with FasterXML Jackson nor with Apache Johnzon (the latter also implementing Jakarta JSON-B).
To Reproduce
Here's working code with Jackson:
This is the version I created with the latest Yasson version (3.0.4 -- where are the release notes btw?):
Using this code, some files are corrupted like shown above:
The Jackson variant does not suffer from this behaviour. Yasson is mixing in contents from another file into this example file
Expected behaviour
System information:
Additional context
ExecutorService executorService = Executors.newWorkStealingPool();