Hello everyone,
we are working on a university project about transactions in MongoDB.
In particular, we are carrying out some experiments about how the transactions behave in situations like phantom reads, write skew, non-repeatable reads and so on.
We are trying different levels of write and read concern.
It’s not clear to us why, even with a minimum level of read concern, we can’t read data that are modified and committed by concurrent transactions.
For example, we have two transactions, T1 and T2.
These two transactions manipulate three objects, x, y and z. We have a constraint among them, that says x+y=z.
T1 reads x and awaits
T2 reads x and y and does x=x+40 and y=y-40. T2 commits.
Now T1 reads y. T1 reads the old value of y, but with a read concern ‘local’ we would expect to read the new value, so that the constraint is not satisfied, but we are still reading the old value so no phantom read happen.
What’s the difference with the read concern “snapshot” if we keep reading something coherent with the data at the start of transaction?
The anomaly that we can observe is the write skew anomaly, but not the others.
What are we missing?