pgsql: Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by
Date: 2008-03-12 20:11:46
Message-ID: 20080312201146.1EB2A753336@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
pg_listener modifications commanded by LISTEN and UNLISTEN until the end
of the current transaction. This allows us to hold the ExclusiveLock on
pg_listener until after commit, with no greater risk of deadlock than there
was before. Aside from fixing the race condition, this gets rid of a
truly ugly kludge that was there before, namely having to ignore
HeapTupleBeingUpdated failures during NOTIFY. There is a small potential
incompatibility, which is that if a transaction issues LISTEN or UNLISTEN
and then looks into pg_listener before committing, it won't see any resulting
row insertion or deletion, where before it would have. It seems unlikely
that anyone would be depending on that, though.

This patch also disallows LISTEN and UNLISTEN inside a prepared transaction.
That case had some pretty undesirable properties already, such as possibly
allowing pg_listener entries to be made for PIDs no longer present, so
disallowing it seems like a better idea than trying to maintain the behavior.

Modified Files:
--------------
pgsql/doc/src/sgml/ref:
prepare_transaction.sgml (r1.6 -> r1.7)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/prepare_transaction.sgml?r1=1.6&r2=1.7)
pgsql/src/backend/commands:
async.c (r1.138 -> r1.139)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/async.c?r1=1.138&r2=1.139)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2008-03-12 20:11:54 pgsql: Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by
Previous Message Bruce Momjian 2008-03-12 19:41:23 pgsql: Add: > > * Consider a special data type for regular expressions