Re: FOR PORTION OF code review

From: Andres Freund <andres(at)anarazel(dot)de>
To: pj(at)illuminatedcomputing(dot)com, peter(at)eisentraut(dot)org
Cc: rmt(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: FOR PORTION OF code review
Date: 2026-09-11 17:30:43
Message-ID: 6lbh27m3epz5glwbpepdwh6xxi4adry2dyg27s2z7dc7xkzq5k@ceyuortazlv2
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-09-11 12:49:54 -0400, Andres Freund wrote:
> I wonder if there may be additional issues with DELETE ... FOR PORTION OF, due
> to not having a ctid chain to follow.

Yep. There's lost updates even with full-key locks, once DELETE FPO enters the
picture.

See the AI generated spec file (although I really needed to force both Opus 5
and Fable 5.1 to get to it, they both swore up and down that this isn't a real
issue at first).

The problem is that with UPDATE FPO different backends serialize on the
surviving row, allowing only one backend to acquire the FOR UPDATE lock on
that row, with the other transaction waiting for the second transaction to
either abort, or to lock the subsequent row.

But with DELETE FPO, there's no such serialization, once the first transaction
commits all concurrent FOR UPDATEs complete, *without* needing a row lock.

So I think either FPO needs a fair bit more work (e.g. using the speculative
insert infrastructure from ON CONFLICT and/or perhaps some careful scanning
with a dirty snapshot), or the feature ought to just refuse to be used with
READ COMMITTED. I'm a bit sceptical that the latter is acceptable. And the
former seems very clearly out of scope for 19.

Greetings,

Andres Freund

Attachment Content-Type Size
for-portion-of-lost-delete2.spec text/plain 2.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2026-09-11 17:31:29 [RFC] An ETW backend for the static probes on Windows
Previous Message Melanie Plageman 2026-09-11 17:24:17 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)