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 1tqdLi-0086Z3-0s for pgsql-admin@arkaria.postgresql.org; Fri, 07 Mar 2025 19:27:10 +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 1tqdKi-00FatX-3F for pgsql-admin@arkaria.postgresql.org; Fri, 07 Mar 2025 19:26:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tqdKh-00FasH-N2 for pgsql-admin@lists.postgresql.org; Fri, 07 Mar 2025 19:26:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tqdKd-001YUq-2d for pgsql-admin@lists.postgresql.org; Fri, 07 Mar 2025 19:26:07 +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 527JQ31J1117737; Fri, 7 Mar 2025 14:26:03 -0500 From: Tom Lane To: Joseph Hammerman cc: pgsql-admin@lists.postgresql.org Subject: Re: Getting out ahead of OOM In-reply-to: References: Comments: In-reply-to Joseph Hammerman message dated "Fri, 07 Mar 2025 11:07:58 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1117735.1741375563.1@sss.pgh.pa.us> Date: Fri, 07 Mar 2025 14:26:03 -0500 Message-ID: <1117736.1741375563@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Joseph Hammerman writes: > We run Postgres in a Kubernetes environment, and we have not to date been > able to convince our Compute team to create a class of Kubernetes hosts > that have memory overcommit disabled. :-( > Has anyone had success tracking all the Postgres memory allocation > configurables and using that to administratively prevent OOMing? I doubt anyone has tried that. I would look into whether running the postmaster under a suitable ulimit helps. I seem to recall discussions that in Linux, "ulimit -v" works better than the other likely-looking options. But that might be stale information. > Alternatively, has anyone has success implementing an extension or periodic > process to monitor the memory consumption of the Postgres children and > killing them before the OOM event occurs? That's not going to be noticeably nicer than the kernel-induced OOM, I think. The one thing it might do for you is ensure that the kill happens to a child process and not the postmaster; but you can already use PG_OOM_ADJUST_VALUE and PG_OOM_ADJUST_FILE to manage that if it's a problem. (Recent kernels are alleged to usually do the right thing without that, though.) regards, tom lane