max_memory_per_backend GUC to limit backend's memory usage - Mailing list pgsql-hackers

From Vladimir Sitnikov
Subject max_memory_per_backend GUC to limit backend's memory usage
Date
Msg-id CAB=Je-FOuN4Z0itYxxMz3=RZi0BO8ZaJznB6eOfMQU9_TKhaMQ@mail.gmail.com
Whole thread Raw
Responses Re: max_memory_per_backend GUC to limit backend's memory usage  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

I've got a problem with PostgreSQL 9.6.5: backend gets killed by OOM killer, and it shuts the DB down.
Of course, the OOM case is to be investigated (MemoryContextStatsDetail, etc), however I wonder if DB can be more robust.
The sad thing is a single backend crash results in the DB shutdown, so it interrupts lots of transactions.

I wonder if a GUC can be implemented, so it could fail just a single backend by limiting its memory use.
For instance: max_mememory_per_backend=100MiB.
The idea is to increase stability by limiting each process. Of course it would result in "out of memory" in case a single query requires 100500MiB (e.g. it misunderestimates the hash join). As far as I understand, it should be safer to terminate just one bad backend rather than kill all the processes.

I did some research, and I have not found the discussion of this idea.

Vladimir Rusinov> FWIW, lack of per-connection and/or global memory limit for work_mem is major PITA

Vladimir

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [HACKERS] Surjective functional indexes
Next
From: Andres Freund
Date:
Subject: Re: max_memory_per_backend GUC to limit backend's memory usage