Description
Hi guys!
Im having the following issue.
I have a rest API that when It receives multiple calls to the same endpoint I end up loosing data.
For the sake of the issue I made up a simple example. It has two models: A
and B
, and A
has a List<B>
The goal is to add Bs to A.
The example has 3 branches with-out-version
, with-version
and with-retry
. To simulate the concurrency I created Executors.newFixedThreadPool(10)
.
The issue: I start with a fresh A (empty list of B). Then, each thread attempts to find that A and add a new B.
Each thread succeeded to create a new B (it shows up in neo4j), but only 1 thread succeded to add that B into A.
With out version: the explained above
With version: I get the optimistic lock exception.
With version+retry: No more exception, but I end up with the initial behaviour.
Let me know if this is or isn't enough information, or If I'm taking a totally wrong aproach!
Thanks for you awesome work :D