Re: One PG process eating more than 40GB of RAM and getting killed by OOM

From: Michael Banck <mbanck(at)gmx(dot)net>
To: Jean-Christophe Boggio <postgresql(at)thefreecat(dot)org>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: One PG process eating more than 40GB of RAM and getting killed by OOM
Date: 2023-10-13 13:13:38
Message-ID: 65294283.050a0220.4c49b.0ac4@mx.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

On Fri, Oct 13, 2023 at 03:06:57PM +0200, Jean-Christophe Boggio wrote:
> On my dev laptop, I have ~40GB free RAM. When launching a heavy calculation
> in PostgreSQL (within a stored procedure), it consumes as much memory as is
> available and then gets killed by OOM. There is only one connected session.
>
> I have the following settings, which look reasonable (to me):
>
> shared_buffers = 512MB                  # min 128kB

That's not a lot.

> work_mem = 1GB                          # min 64kB

On the other hand, that's a lot. So if that query is run in parallel and
has a lot of different things it does, it might use work_mem several
times over, resulting in a lot of used memory.

So first thing to try would be to lower work_mem to someting much lower
like 64MB or 128MB.

> This is PostgreSQL 14.7 running on Ubuntu 23.04

The other thing you can try is to see whether turning jit off (or just
jit_inline_above_cost = -1) is helping.

Michael

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2023-10-13 13:14:07 Re: Locks analyze
Previous Message Johannes Truschnigg 2023-10-13 13:13:28 Re: One PG process eating more than 40GB of RAM and getting killed by OOM