Re: [PG19] A canceled notify read leaves the NOTIFY queue stuck

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, joel(at)compiler(dot)org, arseniy(dot)mukhin(dot)dev(at)gmail(dot)com
Subject: Re: [PG19] A canceled notify read leaves the NOTIFY queue stuck
Date: 2026-10-26 15:27:08
Message-ID: 636470.1793028428@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

shihao zhong <zhong950419(at)gmail(dot)com> writes:
>> Do we really need a serializable snapshot for reading the notify
>> queue? If we do, can we acquire it before making any important state
>> changes?

> I did some investigation today and I don't think we need a serializable
> snapshot.

I looked at this, and I agree: all we care about in async.c is which
transactions are still running, and there's no particular need to wait
for a safe snapshot before deciding that. (A different way to say
that, perhaps, is that NOTIFY messages are delivered on the same basis
as READ COMMITTED operations, even if your default transaction mode
is higher.)

> So we just need to call GetSnapshotData(), but that needs a snapshot.
> I created a static one in async.c because feels like we should not
> touch snapmgr for encapsulation. If you'd rather keep this in
> snapmgr.c, a small wrapper there would work too.

I don't like that choice at all. The only callers of
GetSnapshotData() are in snapmgr.c and predicate.c, and there are
enough weird optimization-driven assumptions around snapshot
management that I think any new caller had better be in one of those
modules so that people working in that area will notice it. I wrote
a wrapper that documents two of the assumptions I think are involved
here, and there could well be more. See what you think.

regards, tom lane

Attachment Content-Type Size
v3-0001-Don-t-wait-for-a-safe-snapshot-when-reading-the-n.patch text/x-diff 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-10-26 15:32:48 Re: Let's drop support for named POSIX semaphores
Previous Message Jim Jones 2026-10-26 15:26:17 xpath() with CDATA content not cancellable while in libxml2