Search Postgresql Archives

Re: An example needed for Serializable conflict...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux