Re: postgresql transactons not fully isolated

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: postgresql transactons not fully isolated
Date: 2017-06-20 17:57:36
Message-ID: 31202.1497981456@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> Michael Malis via:
> http://malisper.me/postgres-transactions-arent-fully-isolated/ has
> determined that postgresql transactions are not fully isolated even
> when using serializable isolationl level.

> If I prep a table, ints via:
> postgres=# create table ints (n int);
> CREATE TABLE
> postgres=# insert into ints values (1);
> INSERT 0 1
> postgres=# insert into ints values (2);
> INSERT 0 1

> and then run two concurrent in serializable isolation mode
> transactions like this:
> T1: BEGIN
> T1: UPDATE ints SET n = n + 1;
> T2: BEGIN
> T2: DELETE FROM ints where n = 2; -- blocks
> T1: COMMIT; -- T2 frees
> T2: SELECT * FROM ints; -- both rows 2 and 3 visible
> T2: COMMIT:

Hm, I get

ERROR: could not serialize access due to concurrent update

in T2 immediately after T1 commits. What version are you testing?
Are you sure you selected serializable mode for both xacts?
(I think it would work like this even if only T2 is marked
serializable, but didn't test.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-06-20 18:30:58 Re: Missing comment for ResultRelInfo in execnodes.h
Previous Message Tom Lane 2017-06-20 17:43:53 Re: PATCH: Don't downcase filepath/filename while loading libraries