In the 2004 paper "A Read-Only Transaction Anomaly Under Snapshot Isolation" by Alan Fekete et al. (which can be found here and here) the authors state:
We also note that any execution of T1 and T2 (with arbitrary parameter values) without T3 present will always act serializably.
I have tested this claim inside PostgreSQL, like this
create table variables (
name char(1) not null,
value integer not null
);
insert into variables values ('x', 0), ('y', 0);
T2: begin
T2: set transaction isolation level serializable;
T2: select * from variables where name = 'x'
T2: select * from variables where name = 'y'
T1: begin
T1: set transaction isolation level serializable;
T1: select * from variables where name = 'y'
T1: update variables set value = 20 where name = 'y'
T1: commit
T2: update variables set value = -11 where name = 'x'
Connection reset. Reconnect (Y/n):
but as shown, when executing the T2's update, this transaction is aborted (I know this because the client, in the case pgcli
, disconnected), which means that the schedule was not serializable.
What is happening here? Is the authors claim wrong? Is it a bug inside PostgreSQL? Or most probably, I made some mistake I am not aware of?
Thanks