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 1krN5u-0002Is-Lw for pgsql-admin@arkaria.postgresql.org; Mon, 21 Dec 2020 15:27:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krN5r-0005El-Je for pgsql-admin@arkaria.postgresql.org; Mon, 21 Dec 2020 15:27:27 +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 1krN5r-0005ET-C6 for pgsql-admin@lists.postgresql.org; Mon, 21 Dec 2020 15:27:27 +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 1krN5n-0008BW-0g for pgsql-admin@postgresql.org; Mon, 21 Dec 2020 15:27:26 +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 0BLFRIvK492639; Mon, 21 Dec 2020 10:27:18 -0500 From: Tom Lane To: Laurenz Albe cc: frank picabia , pgsql-admin@postgresql.org Subject: Re: Error: "could not fork new process for connection: Cannot allocate memory" In-reply-to: References: Comments: In-reply-to Laurenz Albe message dated "Mon, 21 Dec 2020 14:34:58 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <492637.1608564438.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 21 Dec 2020 10:27:18 -0500 Message-ID: <492638.1608564438@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Laurenz Albe writes: > On Mon, 2020-12-21 at 09:17 -0400, frank picabia wrote: >> First of all, we did not run out of memory within the OS. This system = is monitored by cacti and >> Real Used memory never exceeded 30 GB on a server having 64 GB ram plus= some swap. > You probably have to increase the operating system limit for open files > for the "postgres" user (ulimit -n). Isn't ulimit -n a per-process, not per-user, limit? Perhaps ulimit -u (max user processes) would be worth checking, though. However, I don't think I believe the assertion that the system wasn't under overall memory pressure. What we see in the quoted log fragment is two separate postmaster fork-failure reports interspersed with a memory context map, which has to have been coming out of some other process because postmaster.c does not dump its contexts when reporting a fork failure. But there's no reason for a PG process to dump a context map unless it suffered an ENOMEM allocation failure. (It'd be interesting to look for the "out of memory" error that presumably follows the context map, to see if it offers any more info.) So what we have is fork() being unhappy concurrently with ENOMEM problems in at least one other process. That smells like overall memory pressure to me, cacti or no cacti. If you've got cgroups enabled, or if the whole thing is running inside a VM, there might be kernel-enforced memory limits somewhere. regards, tom lane