Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponing
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Mar 2008 20:12:39 +0000 (20:12 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Mar 2008 20:12:39 +0000 (20:12 +0000)
commitd272e2f8d8535eca4033fdba15982c1576452253
tree8ad425e397b46cd5096a6c51c73fe5550db269b1
parent781b5f4cebe3b845c5b49953f7e7c952e949e9b7
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.
src/backend/commands/async.c