If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Read Commited exception

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-20-11, 11:31
eminem eminem is offline
Registered User
 
Join Date: May 2011
Posts: 2
Read Commited exception

Hi,

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:
r1(A)->r2(A)->w1(A)->c1->w2(A)->c2

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.

I would be happy if someone could help me. Thanks
Reply With Quote
  #2 (permalink)  
Old 05-22-11, 05:09
rski rski is offline
Registered User
 
Join Date: Nov 2006
Posts: 82
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.

This may help a little
PostgreSQL: Documentation: Manuals: PostgreSQL 9.0: Explicit Locking
PostgreSQL: Documentation: Manuals: PostgreSQL 9.0: LOCK
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On