aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-02-13 17:12:10 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-02-13 17:12:10 +0000
commit099186df32adfb41fe1daca916363469d5c28584 (patch)
tree1eab307d331aa70b5da6d47fb1dc69ddac16664f /src/backend/commands
parent09406122347f04025b03bab3daa248a9004c1e4b (diff)
downloadpostgresql-099186df32adfb41fe1daca916363469d5c28584.tar.gz
postgresql-099186df32adfb41fe1daca916363469d5c28584.zip
Fix UNLISTEN to fall out quickly if the current backend has never executed
any LISTEN command. This is more important than it used to be because DISCARD ALL invokes UNLISTEN. Connection-pooled applications making heavy use of DISCARD ALL were seeing significant contention for pg_listener, as reported by Matteo Beccati. It seems unlikely that clients using LISTEN would use pooled connections, so this simple tweak seems sufficient, especially since the pg_listener implementation is slated to go away soon anyway. Back-patch to 8.3, where DISCARD ALL was introduced.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/async.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 06ba738fd47..38fc57393e6 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.138.2.1 2008/03/12 20:11:54 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.138.2.2 2009/02/13 17:12:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -283,6 +283,10 @@ Async_Unlisten(const char *relname)
if (Trace_notify)
elog(DEBUG1, "Async_Unlisten(%s,%d)", relname, MyProcPid);
+ /* If we couldn't possibly be listening, no need to queue anything */
+ if (pendingActions == NIL && !unlistenExitRegistered)
+ return;
+
queue_listen(LISTEN_UNLISTEN, relname);
}
}
@@ -298,6 +302,10 @@ Async_UnlistenAll(void)
if (Trace_notify)
elog(DEBUG1, "Async_UnlistenAll(%d)", MyProcPid);
+ /* If we couldn't possibly be listening, no need to queue anything */
+ if (pendingActions == NIL && !unlistenExitRegistered)
+ return;
+
queue_listen(LISTEN_UNLISTEN_ALL, "");
}