Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    2

    Unanswered: 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

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •