From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Durumdara *EXTERN*" <durumdara(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: An example needed for Serializable conflict... |
Date: | 2009-07-07 09:36:03 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C202FF66AD@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Durumdara wrote:
> Please send me an example (pseudo-code) for Serializable conflict.
> And I wanna know, if possible, that if more transactions only
> read the tables in Serializable mode, and one or others write
> to it, can I got some conflicts in read operation?
You get a serialization conflict if you try to modify a row
in a serializable transaction T1 that has been changed by a second
transaction T2 after T1 started.
Sample 1:
T1: START TRANSACTION ISOLATION LEVEL SERIALIZABLE;
T1: SELECT * FROM t;
id | val
----+------
1 | test
(1 row)
T2: DELETE FROM t WHERE id=1;
T1: UPDATE t SET val='new' WHERE id=1;
ERROR: could not serialize access due to concurrent update
Sample 2:
T1: START TRANSACTION ISOLATION LEVEL SERIALIZABLE;
T1: SELECT * FROM t;
id | val
----+------
1 | test
(1 row)
T2: UPDATE t SET val=val WHERE id=1;
T1: DELETE FROM t;
ERROR: could not serialize access due to concurrent update
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Verite | 2009-07-07 10:07:48 | Re: Feistel cipher, shorter string and hex to int |
Previous Message | Albe Laurenz | 2009-07-07 09:12:36 | Re: Efficiently move data from one table to another, with FK constraints? |