Re: Getting out ahead of OOM

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph Hammerman <joe(dot)hammerman(at)datadoghq(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Getting out ahead of OOM
Date: 2025-03-07 19:26:03
Message-ID: 1117736.1741375563@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Joseph Hammerman <joe(dot)hammerman(at)datadoghq(dot)com> 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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Rui DeSousa 2025-03-07 20:17:37 Re: Getting out ahead of OOM
Previous Message Joseph Hammerman 2025-03-07 19:07:58 Getting out ahead of OOM