Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mphxb-0001j1-37 for pgsql-general@arkaria.postgresql.org; Wed, 24 Nov 2021 02:24:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mphxZ-0003Kw-Qg for pgsql-general@arkaria.postgresql.org; Wed, 24 Nov 2021 02:24:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mphxZ-0003Kn-Fa for pgsql-general@lists.postgresql.org; Wed, 24 Nov 2021 02:24:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mphxX-0000mz-6F for pgsql-general@postgresql.org; Wed, 24 Nov 2021 02:24:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1AO2OSpv081461; Tue, 23 Nov 2021 21:24:28 -0500 From: Tom Lane To: James Sewell cc: pgsql-general Subject: Re: Max connections reached without max connections reached In-reply-to: References: <4176160.1637681607@sss.pgh.pa.us> <67613.1637709271@sss.pgh.pa.us> Comments: In-reply-to James Sewell message dated "Wed, 24 Nov 2021 10:53:29 +1100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <81459.1637720668.1@sss.pgh.pa.us> Date: Tue, 23 Nov 2021 21:24:28 -0500 Message-ID: <81460.1637720668@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk James Sewell writes: >> I'm also wondering a bit about whether they're being blocked on a lock, >> eg. due to something taking an exclusive lock on pg_authid or pg_database. >> pg_locks might be interesting to check. > postgres=# select * from pg_locks where not granted; The hypothesis I'm thinking of is that incoming sessions are being blocked somewhere before they can acquire a ProcArray entry; if so, they'd not show up in either pg_stat_activity or pg_locks. What we have to look for then is evidence of somebody holding a strong lock on a shared relation. Try "select * from pg_locks where locktype = 'relation' and database = 0". regards, tom lane