say I want to do the following transactions in read commited mode.
T1: r(A) -> w(A)
T2: r(A) -> w(A)
If the operations where called in this order:
I would exspect that T2 has to wait at r(A). Because T1 would set an exclusive lock for A at the first read, because it wants to write it later. But with MVCC there are are no read locks?
Now i've got 2 questions:
If I use JDBC to read some data and then execute a separte command for inserting the read data. How does the database know that it has to make an exclusiv lock when it is only reading? Increasing an read lock to a write lock is not allowed in 2PL, as far as I know.
I think my assumtions are wrong... Where does this szenario wait or is one transaction killed? Read uncommited shouldn't allow lost updates, but I can't see how this can work.
If there are no keys (primary, unique) insert the same insert will succeded in both sessions. There is no need for exclusive lock while reading because both transaction use table snapshots while processing.