When using Javers and Spring Boot applications (with MongoDB) in distributed environments, I get incorrect auditing snapshots.
How to recreate (assuming we have 2 servers) -
The last generated auditing data will contain previousValue as it was on request 1 and the currentValue as it is on request 3.
Currently, I have fixed the issue by disabling javers cache by setting the following property javers.snapshotsCacheSize=0.
Is there any way to keep javers cache consistent in distributed environments?
There is no such way. Javers uses local cache only. I didnt tested it but I dont think that adding a distributed cache layer would significantly speed things up. It would add additional overhead. But if you are interested in contributing that feature - we can talk about it here https://github.com/javers/javers/discussions