The first-committer-wins guarantee may be broken if the (conflict check + Memtable insert) is not atomic. Especially under high concurrency.
Scenario (assume T1 and T2 run concurrently):
T1 Begin
T2 Begin
T1 write X
T2 write X
T1 call commit() in transaction
T2 call commit() in transaction
T1 check → no conflict (validate_write_conflicts function)
T2 check → no conflict (validate_write_conflicts function) // T1 may not be in memtable yet, so T2 can't figure out that there is a write write conflict.
Now both transactions commit, which violates first-committer-wins in same snapshot.
The first-committer-wins guarantee may be broken if the (conflict check + Memtable insert) is not atomic. Especially under high concurrency.
Scenario (assume T1 and T2 run concurrently):
T1 Begin
T2 Begin
T1 write X
T2 write X
T1 call commit() in transaction
T2 call commit() in transaction
T1 check → no conflict (validate_write_conflicts function)
T2 check → no conflict (validate_write_conflicts function) // T1 may not be in memtable yet, so T2 can't figure out that there is a write write conflict.
Now both transactions commit, which violates first-committer-wins in same snapshot.