pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Client-side fixes for delayed NOTIFY receipt.
Date: Sat, 20 Oct 2018 02:23:15 +0000
Message-ID: <E1gDgv5-0005Xt-9o@gemulon.postgresql.org> (raw)

Client-side fixes for delayed NOTIFY receipt.

PQnotifies() is defined to just process already-read data, not try to read
any more from the socket.  (This is a debatable decision, perhaps, but I'm
hesitant to change longstanding library behavior.)  The documentation has
long recommended calling PQconsumeInput() before PQnotifies() to ensure
that any already-arrived message would get absorbed and processed.
However, psql did not get that memo, which explains why it's not very
reliable about reporting notifications promptly.

Also, most (not quite all) callers called PQconsumeInput() just once before
a PQnotifies() loop.  Taking this recommendation seriously implies that we
should do PQconsumeInput() before each call.  This is more important now
that we have "payload" strings in notification messages than it was before;
that increases the probability of having more than one packet's worth
of notify messages.  Hence, adjust code as well as documentation examples
to do it like that.

Back-patch to 9.5 to match related server fixes.  In principle we could
probably go back further with these changes, but given lack of field
complaints I doubt it's worthwhile.

Discussion: https://postgr.es/m/CAOYf6ec-TmRYjKBXLLaGaB-jrd=mjG1Hzn1a1wufUAR39PQYhw@mail.gmail.com

Branch
------
REL9_5_STABLE

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

Modified Files
--------------
doc/src/sgml/libpq.sgml               | 3 ++-
src/bin/psql/common.c                 | 4 +++-
src/interfaces/ecpg/ecpglib/execute.c | 5 +++--
src/interfaces/libpq/fe-exec.c        | 3 +++
src/test/examples/testlibpq2.c        | 1 +
5 files changed, 12 insertions(+), 4 deletions(-)



view thread (5+ messages)

Message-ID: <E1gDgv5-0005Xt-9o@gemulon.postgresql.org>
Permalink:  ../E1gDgv5-0005Xt-9o@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gDgv5-0005Xt-9o@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Client-side fixes for delayed NOTIFY receipt.
  In-Reply-To: <E1gDgv5-0005Xt-9o@gemulon.postgresql.org>
  References: <E1gDgv5-0005Xt-9o@gemulon.postgresql.org>

* 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