pgsql: Stabilize NOTIFY behavior by transmitting notifies before ReadyF

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Stabilize NOTIFY behavior by transmitting notifies before ReadyF
Date: 2019-11-24 19:43:19
Message-ID: E1iYxmx-000874-Ux@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Stabilize NOTIFY behavior by transmitting notifies before ReadyForQuery.

This patch ensures that, if any notify messages were received during
a just-finished transaction, they get sent to the frontend just before
not just after the ReadyForQuery message. With libpq and other client
libraries that act similarly, this guarantees that the client will see
the notify messages as available as soon as it thinks the transaction
is done.

This probably makes no difference in practice, since in realistic
use-cases the application would have to cope with asynchronous
arrival of notify events anyhow. However, it makes it a lot easier
to build cross-session-notify test cases with stable behavior.
I'm a bit surprised now that we've not seen any buildfarm instability
with the test cases added by commit b10f40bf0. Tests that I intend
to add in an upcoming bug fix are definitely unstable without this.

Back-patch to 9.6, which is as far back as we can do NOTIFY testing
with the isolationtester infrastructure.

Discussion: https://postgr.es/m/13881.1574557302@sss.pgh.pa.us

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dbe15524becb0d1366e9421aabdf85f538001942

Modified Files
--------------
src/backend/commands/async.c | 12 +++++++-----
src/backend/tcop/postgres.c | 11 +++++++++++
2 files changed, 18 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2019-11-24 20:28:12 pgsql: doc: Fix whitespace in syntax.
Previous Message Tom Lane 2019-11-24 19:09:45 pgsql: Stabilize the results of pg_notification_queue_usage().