From: Takeshi Ideriha <iderihatakeshi@gmail.com>
To: pgsql-hackers@postgresql.org
Subject: Fix doc: explanation of how postgres works when OOM killer is invoked
Date: Thu, 8 Oct 2026 12:27:03 +0900
Message-ID: <ce269321-a7f4-48f4-a9ca-a4a4983b9fd6@gmail.com> (raw)
Hi postgres-hackers
While reviewing a doc patch[1] , I noticed that current explanation
about how postgres behaves when an OOM killer is invoked is not quite
correct.
Postgres doc [2] says:
> This indicates that the <filename>postgres</filename> process
> has been terminated due to memory pressure.
> Although existing database connections will continue to function
> normally, no new connections will be accepted. To recover,
> <productname>PostgreSQL</productname> will need to be restarted.
But I believe all postgres processes will be terminated in this case.
When a backend process is terminated by an OOM killer, the whole
postgres will be restarted or stop depending on restart_after_crash
setting. In a special case where postmaster is killed, each backend
proccesses will also eventually be terminated. The backend process will
be stopped when it notices postmaster is terminated. In this case, the
postgres will just stop and a user needs to restart it. I tested above
two cases and checked the relevant codes.
The statement was very old and committed at 02cd2b96acdb in 2003. I
assume it was correct at the time but I believe it's not as of now
though I haven't checked.
Could you check attached patch?
The original document mentions to postmaster explicitly. So, in my patch
I explain how postmaster and other processes work when OOM killer is
invoked.
[1]
https://www.postgresql.org/message-id/flat/CABH8dKwkp1_TzR7nxfvSpRSLD1b33xw7N_VLMLy3MiaEjAEPNw%40mai...
[2]
https://www.postgresql.org/docs/devel/kernel-resources.html#LINUX-MEMORY-OVERCOMMIT
Thank you,
Takeshi Ideriha
Attachments:v1-0001-Fix-explain-how-postgres-behaves-when-an-OOM-kill.patch (text/plain, 1.4K) download
From fe9b822023854b2c87696b31cc040e7158622a67 Mon Sep 17 00:00:00 2001
From: Takeshi Ideriha <iderihatakeshi@gmail.com>
Date: Thu, 8 Oct 2026 10:40:20 +0900
Subject: [PATCH v1] Fix explain how postgres behaves when an OOM killer is
invoked.
---
doc/src/sgml/runtime.sgml | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgmlindex d9984910cc4..3f5641c33bb 100644--- a/doc/src/sgml/runtime.sgml+++ b/doc/src/sgml/runtime.sgml@@ -1359,9 +1359,13 @@ Out of Memory: Killed process 12345 (postgres).
</programlisting>
This indicates that the <filename>postgres</filename> process
has been terminated due to memory pressure.
- Although existing database connections will continue to function- normally, no new connections will be accepted. To recover,- <productname>PostgreSQL</productname> will need to be restarted.+ If the postmaster is terminated, all connections will eventually be+ terminated. To recover, <productname>PostgreSQL</productname> will+ need to be restarted.+ If another server process is terminated, all connections will be terminated+ and <productname>PostgreSQL</productname> will automatically restart when+ <link linkend="guc-restart-after-crash"><varname>restart_after_crash</varname></link>+ is on.
</para>
<para>
--
2.50.1 (Apple Git-155)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: iderihatakeshi@gmail.com
Subject: Re: Fix doc: explanation of how postgres works when OOM killer is invoked
In-Reply-To: <ce269321-a7f4-48f4-a9ca-a4a4983b9fd6@gmail.com>
References: <ce269321-a7f4-48f4-a9ca-a4a4983b9fd6@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox