Hi,

Before implementing optimistic concurrency solution, I had written one test
case to check if two threads atomically writing two different fields (say
f1 and f2) of the same document (say d) run into conflict or not.
Thread t1 atomically writes counter c1 to field f1 of document d, commits
and then reads the value of f1 and makes sure that it is equal to c1. It
then increments c1 by 1 and resumes until c1 reaches to say 1000.
Thread t2 does the same, but with counter c2 and field f2 but with same
document d.
What I observed is the assertion of f1 = c1 or f2 = c2 in each loop never
fails.
I increased the max counter value to even 100000 instead of mere 1000 and
still no conflict
I was under the impression that there would often be conflict and that is
why I will require optimistic concurrency solution. How is this possible?
Any idea?

Here is the test case code:

https://pastebin.com/KCLPYqeg

Reply via email to