What's the correct database behavior when two transactions change the same row/value?
1
vote
1
answer
238
views
I'm writing a database LRU cache in C++ for an embedded NoSQL database to solve a performance problem, and I'm trying to understand the correct assumed behavior and philosophy behind it.
Say there's a NoSQL database at a certain state X. We start transaction 1 (tx1) and start transaction 2 (tx2) from the same isolated state X. Both transactions attempt to change the same key/value pair. Each transaction changes the value to some value, and the two values are not equal. Tx1 commits, then tx2 commits. What's the correct behavior of the database?
1. The new value is the one committed from tx2, because it overwrites tx1
2. The new value is the one committed from tx1, because committing tx2 should fail
Or is the answer something else?
Can someone please elaborate on how such a system should be programmed if it's ACID compliant?
The DB I'm using that I want to cache over is LMDB , which claims to be ACID-compliant.
Asked by The Quantum Physicist
(125 rep)
Aug 26, 2021, 05:43 AM
Last activity: Aug 26, 2021, 04:04 PM
Last activity: Aug 26, 2021, 04:04 PM