Fix LISTEN/NOTIFY race condition reported by Gavin Sherry. While a
authorTom Lane <[email protected]>
Mon, 15 Sep 2003 23:33:43 +0000 (23:33 +0000)
committerTom Lane <[email protected]>
Mon, 15 Sep 2003 23:33:43 +0000 (23:33 +0000)
commitdb18703b5a7970f96142ede2f166513274075f8f
tree9fcb9176dbab2a119c7761c305dee9f293dcc206
parentd73e1b33b57eb4244e43f7f03ce1a2b91d6697b9
Fix LISTEN/NOTIFY race condition reported by Gavin Sherry.  While a
really general fix might be difficult, I believe the only case where
AtCommit_Notify could see an uncommitted tuple is where the other guy
has just unlistened and not yet committed.  The best solution seems to
be to just skip updating that tuple, on the assumption that the other
guy does not want to hear about the notification anyway.  This is not
perfect --- if the other guy rolls back his unlisten instead of committing,
then he really should have gotten this notify.  But to do that, we'd have
to wait to see if he commits or not, or make UNLISTEN hold exclusive lock
on pg_listener until commit.  Either of these answers is deadlock-prone,
not to mention horrible for interactive performance.  Do it this way
for now.  (What happened to that project to do LISTEN/NOTIFY in memory
with no table, anyway?)
src/backend/access/heap/heapam.c
src/backend/commands/async.c
src/backend/executor/execMain.c
src/include/access/heapam.h