Stupid question on Read Committed Isolation Level

From: "Marc G(dot) Fournier" <scrappy(at)hub(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Stupid question on Read Committed Isolation Level
Date: 2004-01-29 17:33:48
Message-ID: 20040129132813.H6922@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


http://www.postgresql.org/docs/7.3/static/transaction-iso.html#XACT-READ-COMMITTED

Reading this:

"
BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7534;
COMMIT;

If two such transactions concurrently try to change the balance of account
12345, we clearly want the second transaction to start from the updated
version of the account's row. Because each query is affecting only a
predetermined row, letting it see the updated version of the row does not
create any troublesome inconsistency.
"

What happens if I abort on the first transaction? If I'm reading this
right, if Trans2 does the exact same as above, and COMMITs before Trans1
Aborts, the value of balance becomes +200 (Trans2 + Trans1) ... but what
happens when Trans1 ABORTS? Trans2 believes its COMMIT worked, but
ABORTng Trans1 will rollback to the original value, no?

Or am I reading that section wrong? :(

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2004-01-29 17:54:21 Re: Stupid question on Read Committed Isolation Level
Previous Message Peter Eisentraut 2004-01-29 17:31:59 Re: returning PGresult as xml