Search Postgresql Archives

Question About Serializable

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

 



The documentation states that "concurrent execution of a set of Serializable transactions is guaranteed to produce the same effect as running them one at a time in some order."

I'm not sure how the following behavior fits that definition. (Note that this is just an experiment, not a use case. Purely academic.) I run these transactions sequentially, and I get a different result than if I run them concurrently.

This is in 9.3.0

First, I set up a table.

create table x (value int);

Then I run the following transactions. If I run them sequentially, in either order, I get one row in table x. If I run them concurrently, I get no rows in x.

It seems like one of these should error out and not commit, so I must be missing some stipulation.

Feel free to repeat this result.

=========
begin;

set transaction isolation level serializable;

create table z ();

select pg_sleep(5);

insert into x (value)
  select 0
  where exists (select relname from pg_class
                where relname = 'y')
    and exists (select relname from pg_class
                where relname = 'z');
commit;

=========
begin;

set transaction isolation level serializable;

create table y ();

select pg_sleep(5);

insert into x (value)
  select 0
  where exists (select relname from pg_class
                where relname = 'y')
    and exists (select relname from pg_class
                where relname = 'z');
commit;



[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