]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Mar 2008 20:11:54 +0000 (20:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Mar 2008 20:11:54 +0000 (20:11 +0000)
commitd2ab94dac23bab41d25f7f5c7814d7d3a4d5b1c4
treea41b416dfc21d08a497a498252e9d495da2f319a
parent32aaf48022f3a91e6c36e24497baee9d22ba7d34
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.
doc/src/sgml/ref/prepare_transaction.sgml
src/backend/commands/async.c