public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: [email protected]
Subject: pgsql: Fix NOTIFY wakeups for pre-commit LISTEN entries.
Date: Wed, 27 May 2026 16:23:56 +0000
Message-ID: <[email protected]> (raw)

Fix NOTIFY wakeups for pre-commit LISTEN entries.

Commit 282b1cde9 made SignalBackends() ignore ListenerEntry entries
whose "listening" flag said that the listener was not yet committed.
That will be true for a new listener that has already registered its
queue position, but has not yet reached AtCommit_Notify().  If another
backend notifies the same channel in that window, SignalBackends()
would directly advance the new listener's queue position, causing it
to miss message(s).  Really this is a definitional question: is a new
listener active as of PreCommit, or as of AtCommit?  But it seems to
make more sense to expect that the new listener will see all messages
after its initially-registered queue position, especially since the
direct-advance logic is supposed to be an optimization that doesn't
affect semantics.

Fix this by treating all channel entries as valid wakeup targets.
Rename the "listening" flag to removeOnAbort to reflect its remaining
purpose: identifying staged LISTEN entries that abort cleanup must
remove.

While we're here, remove an obsolete test case added by 282b1cde9.
The check for "ChannelHashAddListener array growth" was meant to
exercise code that never made it into the committed patch, so now
it's just a waste of test cycles.

Author: Joel Jacobson <[email protected]>
Reviewed-by: Arseniy Mukhin <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f24332aeb4f43409c2a7bec9fef1e3317689bc5

Modified Files
--------------
src/backend/commands/async.c                 | 62 ++++++++++++++--------------
src/test/isolation/expected/async-notify.out | 11 +----
src/test/isolation/specs/async-notify.spec   |  9 ----
3 files changed, 33 insertions(+), 49 deletions(-)



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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Fix NOTIFY wakeups for pre-commit LISTEN entries.
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox