say I want to do the following transactions in read mode (in postgres).
T1: r(A) -> w(A)
T2: r(A) -> w(A)
If the operations called in this order:
r1(A)->r2(A)->w1(A)->c1->w2(A)->c2
I would expect T2 to wait at r (A). Because T1 set an exclusive lock for A on the first read, because he wants to write it down later. But with MVCC there are no read locks?
Now I have 2 questions:
If I use JDBC to read some data, and then run the separte command to insert the read data. How does the database know that it should make an exclusive lock when it is only reading? As far as I know, increasing read lock write lock in 2PL is unacceptable.
I think my assumptions are wrong ... Where is this scenario waiting or is one transaction killed? Reading uncommitted should not allow for lost updates, but I don't see how this might work.
I would be glad if someone could help me. Thanks
user759534
source
share