Re: Write skew observed under serializable isolation

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Write skew observed under serializable isolation
Date: 2026-09-23 13:13:58
Message-ID: CAJ7c6TMEJ7sZhASiK5_VjnO6yfr-yawZ_FFzFYBVRFQWNPm7ig@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Zsolt,

> An isolation test reproducing the problem:
>
> setup
> {
> create table ta (id int);
> insert into ta values (1), (2);
> create table tb (id int);
> insert into tb values (1), (2);
> }
> teardown { drop table ta; drop table tb; }
>
> session s1
> setup { begin isolation level serializable; set enable_seqscan = off; }
> step r1 { select count(*) from tb where ctid = '(0,3)'; }
> step w1 { insert into ta values (100); }
> step c1 { commit; }
>
> session s2
> setup { begin isolation level serializable; set enable_seqscan = off; }
> step r2 { select count(*) from ta where ctid = '(0,3)'; }
> step w2 { insert into tb values (200); }
> step c2 { commit; }
>
> permutation r1 r2 w1 w2 c1 c2

Great find, thanks for reporting.

Technically this is another bug since it affects Tid Scans, not Tid
Range Scans. This being said I see no reason not to fix it in the
scope of this discussion. The proper fix is to acquire SIREAD on the
relation.

Implemented as a separate patch.

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
v5-0001-Fix-write-skew-under-SERIALIZABLE-for-TID-range-s.patch text/x-patch 15.2 KB
v5-0002-Fix-write-skew-under-SERIALIZABLE-for-TID-scans.patch text/x-patch 8.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Sagar Shedge 2026-09-23 13:08:31 Re: postgres_fdw: push down FETCH FIRST .. WITH TIES when server version allows