pgsql: Fix bogus when-to-deregister-from-listener-array logic.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix bogus when-to-deregister-from-listener-array logic.
Date: 2013-02-13 17:48:45
Message-ID: E1U5gRp-0004QN-5Y@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix bogus when-to-deregister-from-listener-array logic.

Since a backend adds itself to the global listener array during
Exec_ListenPreCommit, it's inappropriate for it to remove itself during
Exec_UnlistenCommit or Exec_UnlistenAllCommit --- that leads to failure
when committing a transaction that did UNLISTEN then LISTEN, since we end
up not registered though we should be. (This leads to missing later
notifications, or to Assert failures in assert-enabled builds.) Instead
deal with deregistering at the bottom of AtCommit_Notify, when we know the
final state of the listenChannels list.

Also, simplify the representation of registration status by replacing the
transient backendHasExecutedInitialListen flag with an amRegisteredListener
flag.

Per report from Greg Sabino Mullane. Back-patch to 9.0, where the problem
was introduced during the LISTEN/NOTIFY rewrite.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/52c889ea4f7696157fde4b74ae62fbe014d06087

Modified Files
--------------
src/backend/commands/async.c | 60 +++++++++++++++--------------------------
1 files changed, 22 insertions(+), 38 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-02-13 19:07:56 pgsql: Fix contrib/pg_trgm's similarity() function for trigram-free str
Previous Message Peter Eisentraut 2013-02-13 16:08:56 Re: [COMMITTERS] pgsql: Add noreturn attributes to some error reporting functions