Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tk56s-00HJq2-0F for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Feb 2025 17:40:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tk56q-000otI-EP for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Feb 2025 17:40:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tk56q-000otA-4Z for pgsql-hackers@lists.postgresql.org; Mon, 17 Feb 2025 17:40:44 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tk56o-001MRt-14 for pgsql-hackers@postgresql.org; Mon, 17 Feb 2025 17:40:43 +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 51HHedSB849934; Mon, 17 Feb 2025 12:40:39 -0500 From: Tom Lane To: Andres Freund cc: Jelte Fennema-Nio , Tomas Vondra , PostgreSQL-development Subject: Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup In-reply-to: References: <3203865.1739301613@sss.pgh.pa.us> <94798ef1-0f13-416a-983a-88447e434a7f@vondra.me> <7u7dbn6s2i6bf3hjzkbqaexj2bpoblqxwbkffbetl4rjv6dcom@s2uickjc5z53> <3216369.1739308717@sss.pgh.pa.us> Comments: In-reply-to Andres Freund message dated "Mon, 17 Feb 2025 12:24:46 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <849932.1739814039.1@sss.pgh.pa.us> Date: Mon, 17 Feb 2025 12:40:39 -0500 Message-ID: <849933.1739814039@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2025-02-12 22:52:52 +0100, Jelte Fennema-Nio wrote: >> + /* >> + * Bump the soft limit to the hard limit to not run into low >> + * file limits. >> + */ >> + rlim.rlim_cur = rlim.rlim_max; >> + if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) >> + pg_fatal("setrlimit failed: %m"); >> + >> if (rlim.rlim_cur < nclients + 3) > Why not do this only in the if (rlim.rlim_cur < nclients + 3) case? +1, otherwise you're introducing a potential failure mode for nothing. It'd take a couple extra lines to deal with the scenario where rlim_max is still too small, but that seems fine. > Other than this I think we should just apply this. Agreed on the pgbench change. I don't have an opinion yet on the server changes. regards, tom lane