pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com>
Cc: Joel Jacobson <joel@compiler.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue
Date: Wed, 5 Nov 2025 11:21:29 +0200
Message-ID: <fedbd908-4571-4bbe-b48e-63bfdcc38f64@iki.fi> (raw )
In-Reply-To: <CAE7r3M+ZE1UR7cC1bTsesFLzP1v24=Hk1kwBRuqDmJsrTNMuRA@mail.gmail.com >
References: <DDOYDH17RU0G.1R4MKAZKP87QV@gmail.com >
<202510221548.tgggefdrlpo3@alvherre.pgsql >
<DDP0YT14VYUG.34K8AP6EHU2TR@gmail.com >
<CAD21AoBKTF9SKSANX3xeXV9NjyDGYJeYEFN4duf--Tk=_exTYQ@mail.gmail.com >
<CAE7r3MJK9irHqpZ9vfRmz-BZSjwq4oyjR4ppmaMp2g2GePf55g@mail.gmail.com >
<DDQZBKAC1KZ4.3LT22J6Q74JV0@gmail.com >
<CAE7r3MJgJj4D_6mPHMr-4xCrYK7q04M3jM1J_=4baphjA2WeBA@mail.gmail.com >
<149c402d-54c9-48dd-a730-2f5b958f2129@app.fastmail.com >
<769bbdba-f86f-44ad-abad-f6ea4f74e3f2@iki.fi >
<2297af80-dd5d-4fcc-815b-75bd64b00bf9@app.fastmail.com >
<2759499.1761756503@sss.pgh.pa.us >
<6ae4acd3-6c57-4271-bc24-634fd1b11d67@iki.fi >
<e1e4909b-66b9-43d8-8942-529b7519c758@app.fastmail.com >
<c37cae90-0564-4798-89e1-5dfb8c6d2cba@app.fastmail.com >
<dc6b131d-b010-401e-951e-48535bfb5861@iki.fi >
<badd3b04-ce9f-4f29-9b42-05e5cc545058@iki.fi >
<68079c62-2fe9-4489-b68d-3b1b911ebd59@app.fastmail.com >
<66213fee-00ff-4952-802d-c06454e521ac@iki.fi >
<CAE7r3M+ZE1UR7cC1bTsesFLzP1v24=Hk1kwBRuqDmJsrTNMuRA@mail.gmail.com >
On 04/11/2025 16:40, Arseniy Mukhin wrote:
> It seems that 0002 handles errors during NotifyMyFrontEnd a little differently.
>
> With master, in case of a failure during NotifyMyFrontEnd, the
> listener's position in PG_FINALLY is set to the beginning of the next
> notification, since we advance the "current" position only if the
> previous notification was successfully sent.
>
> With 0002, we advance the "current" position while copying
> notifications to the local buffer, and begin sending them after the
> position has already been advanced for all copied notifications. So in
> case of a failure, the listener's position in PG_FINALLY is set to the
> beginning of the next page or queue head. This means we can lose
> notifications that were copied but were not sent.
True.
> If we want to preserve the previous behavior, maybe we could use a new
> local position while copying notifications and only advance the
> "current" position while sending notifications to the frontend?
That's not good. The loop advances 'current' before calling
TransactionIdDidCommit() to ensure that if there's a broken entry in the
queue for which TransactionIdDidCommit() throws an error, we advance
'current' past that point. Otherwise we would get back later to try to
process the same broken entry again and again.
We could put the NotifyMyFrontEnd() calls in a PG_FINALLY block, so that
the copied notifications get sent even on error. But I'm a reluctant to
put that in PG_FINALLY, it's not clear to me if NotifyMyFrontEnd() is
safe to call during error processing. And if the client is not
processing the notifications, the abort processing could be delayed for
a long time.
One idea is to close the client connection on a TransactionIdDidCommit
error, i.e. make the error FATAL. The current behavior where we skip the
notification seems problematic already. Closing the connection would be
a clear signal that some notifications have been lost.
Or we can just accept new behavior that if TransactionIdDidCommit()
fails, we might lose more notifications than the one that caused the error.
- Heikki
view thread (99+ messages) latest in thread
Message-ID: <fedbd908-4571-4bbe-b48e-63bfdcc38f64@iki.fi>
Permalink: ../fedbd908-4571-4bbe-b48e-63bfdcc38f64@iki.fi/
Also on: postgresql.org/message-id/fedbd908-4571-4bbe-b48e-63bfdcc38f64@iki.fi
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: hlinnaka@iki.fi, arseniy.mukhin.dev@gmail.com, joel@compiler.org, tgl@sss.pgh.pa.us
Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue
In-Reply-To: <fedbd908-4571-4bbe-b48e-63bfdcc38f64@iki.fi>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox