From 6d6e44166f58e4b6a5e8c7474ea3cc7d65449ef7 Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Fri, 29 Jul 2022 14:05:41 +0200 Subject: [PATCH] Avoid catalog read via superuser() call in DecrementSharedConnectionCounter --- .../distributed/connection/shared_connection_stats.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/distributed/connection/shared_connection_stats.c b/src/backend/distributed/connection/shared_connection_stats.c index 82a35473384..82ad2675673 100644 --- a/src/backend/distributed/connection/shared_connection_stats.c +++ b/src/backend/distributed/connection/shared_connection_stats.c @@ -420,7 +420,7 @@ IncrementSharedConnectionCounter(const char *hostname, int port) { SharedConnStatsHashKey connKey; - if (GetMaxSharedPoolSize() == DISABLE_CONNECTION_THROTTLING) + if (MaxSharedPoolSize == DISABLE_CONNECTION_THROTTLING) { /* connection throttling disabled */ return; @@ -484,7 +484,11 @@ DecrementSharedConnectionCounter(const char *hostname, int port) { SharedConnStatsHashKey connKey; - if (GetMaxSharedPoolSize() == DISABLE_CONNECTION_THROTTLING) + /* + * Do not call GetMaxSharedPoolSize() here, since it may read from + * the catalog and we may be in the process exit handler. + */ + if (MaxSharedPoolSize == DISABLE_CONNECTION_THROTTLING) { /* connection throttling disabled */ return;