Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group