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 1oQKjf-0002kl-2w for pgsql-performance@arkaria.postgresql.org; Tue, 23 Aug 2022 03:37:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oQKjd-0001cx-S7 for pgsql-performance@arkaria.postgresql.org; Tue, 23 Aug 2022 03:37:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQKjd-0001co-Iz for pgsql-performance@lists.postgresql.org; Tue, 23 Aug 2022 03:37:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQKjb-0001EK-A2 for pgsql-performance@lists.postgresql.org; Tue, 23 Aug 2022 03:37:48 +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 27N3bhAZ476558; Mon, 22 Aug 2022 23:37:43 -0400 From: Tom Lane To: Junwang Zhao cc: Thomas Munro , Andrew Dunstan , Kevin McKibbin , pgsql-performance@lists.postgresql.org Subject: Re: pgbench: could not connect to server: Resource temporarily unavailable In-reply-to: References: <3909995.1661052002@sss.pgh.pa.us> <35d221aa-3da4-f744-3965-ceca7f71f4ea@dunslane.net> <8864.1661116501@sss.pgh.pa.us> <83134bb1-3a21-059f-1cd6-4997de2652b8@dunslane.net> <33898.1661118503@sss.pgh.pa.us> <68893.1661122531@sss.pgh.pa.us> <84184.1661127637@sss.pgh.pa.us> <105986.1661134693@sss.pgh.pa.us> <114075.1661136913@sss.pgh.pa.us> <361175.1661187463@sss.pgh.pa.us> Comments: In-reply-to Junwang Zhao message dated "Tue, 23 Aug 2022 11:12:07 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <476556.1661225863.1@sss.pgh.pa.us> Date: Mon, 22 Aug 2022 23:37:43 -0400 Message-ID: <476557.1661225863@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Junwang Zhao writes: > Just curious, *backlog* defines the maximum pending connections, > why do we need to double the MaxConnections as the queue size? The postmaster allows up to twice MaxConnections child processes to exist, per the comment in canAcceptConnections: * We allow more connections here than we can have backends because some * might still be authenticating; they might fail auth, or some existing * backend might exit before the auth cycle is completed. The exact * MaxBackends limit is enforced when a new backend tries to join the * shared-inval backend array. You can argue that 2X might not be the right multiplier, and you can argue that the optimal listen queue length might be more or less than the limit on number of child processes, but that's how we've historically done it. I'm not especially interested in changing that without somebody making a well-reasoned case for some other number. regards, tom lane