Re: Write skew observed under serializable isolation

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Write skew observed under serializable isolation
Date: 2026-07-27 09:12:54
Message-ID: CAEze2WgDVoO4H4u9f3WazWMHEv7qM=+UzXgV6wQU6_MzfNAcmA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 27 Jul 2026 at 07:58, Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com> wrote:
>
> Hi hackers,
>
> I found that a query using a Tid Range Scan can allow write skew under `SERIALIZABLE`.

Good find!

On Mon, 27 Jul 2026 at 08:05, Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com> wrote:
>
> A candidate patch to fix is attached.

I think this patch is taking locks too aggressively; we shouldn't take
a predlock on the whole relation when we're only looking at a small
portion of the table using TID ranges. I think the more appropriate
place to add the predicate locks is in heap_set_tidrange(), and have
Assert(PageIsPredicateLocked(...)) for the returned TID in
heap_getnextslot_tidrange() to make sure we don't regress.

Kind regards,

Matthias van de Meent.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2026-07-27 09:17:44 Re: Tracking per-RelOptInfo uniqueness during planning
Previous Message Peter Smith 2026-07-27 08:57:19 Re: Support EXCEPT for ALL SEQUENCES publications