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 1thvnv-008jTl-Up for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2025 19:20:19 +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 1thvnu-00EfmY-MH for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2025 19:20:18 +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 1thvnu-00EfmQ-D5 for pgsql-hackers@lists.postgresql.org; Tue, 11 Feb 2025 19:20:18 +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 1thvns-000HBN-20 for pgsql-hackers@postgresql.org; Tue, 11 Feb 2025 19:20:17 +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 51BJKDa33203866; Tue, 11 Feb 2025 14:20:13 -0500 From: Tom Lane To: Jelte Fennema-Nio cc: PostgreSQL-development , Andres Freund Subject: Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup In-reply-to: References: Comments: In-reply-to Jelte Fennema-Nio message dated "Tue, 11 Feb 2025 19:52:34 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3203864.1739301613.1@sss.pgh.pa.us> Date: Tue, 11 Feb 2025 14:20:13 -0500 Message-ID: <3203865.1739301613@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jelte Fennema-Nio writes: > The default open file limit of 1024 is extremely low, given modern > resources and kernel architectures. The reason that this hasn't changed > change is because doing so would break legacy programs that use the > select(2) system call in hard to debug ways. So instead programs that > want to opt-in to a higher open file limit are expected to bump their > soft limit to their hard limit on startup. Details on this are very well > explained in a blogpost by the systemd author[1]. On a handy Linux machine (running RHEL9): $ ulimit -n 1024 $ ulimit -n -H 524288 I'm okay with believing that 1024 is unreasonably small, but that doesn't mean I think half a million is a safe value. (Remember that that's *per backend*.) Postgres has run OSes out of FDs in the past and I don't believe we couldn't do it again. Also, the argument you cite is completely recent-Linux-centric and does not consider the likely effects on other platforms. To take one example, on current macOS: $ ulimit -n 4864 $ ulimit -n -H unlimited (Hm, so Apple wasn't impressed by the "let's not break select(2)" argument. But I digress.) I'm afraid this patch will replace "you need to tune ulimit -n to get best performance" with "you need to tune ulimit -n to avoid crashing your system". Does not sound like an improvement. Maybe a sanity limit on how high we'll try to raise the ulimit would help. regards, tom lane