From: Joe Conway <mail@joeconway.com>
To: kaido vaikla <kaido.vaikla@gmail.com>
To: pgsql-admin@postgresql.org
Subject: Re: Invoke OOM killer
Date: Thu, 6 Jul 2023 13:12:35 -0400
Message-ID: <47cb8d14-7288-945e-19d1-655b8117960e@joeconway.com> (raw)
In-Reply-To: <CA+427g8Cg1HVzWVBWPHAgeVNOLdghL1ovrDL_+55KJRG_xERCg@mail.gmail.com>
References: <CA+427g8Cg1HVzWVBWPHAgeVNOLdghL1ovrDL_+55KJRG_xERCg@mail.gmail.com>
On 7/6/23 12:27, kaido vaikla wrote:
> Hi,
>
> How to invoke OOM killer for pg process?
> Some easy "hack" for test purpose.
>
> OS
> Rocky Linux release 9.2 (Blue Onyx)
> pg
> 15.2
If you are running postgres under systemd, you can add a cgroup memory
limit to the unit file. Something like (depending on cgroup version and
systemd version the params might be slightly different -- cannot
remember off the top of my head):
-------
MemoryAccounting=yes
MemoryMax=256M
-------
Don't forget to
-------
systemctl daemon-reload
systemctl restart postgresql@15
#or whatever version
-------
That will cause an OOM killer strike at 256M of total cgroup usage (all
of the postgres processes combined).
From there it is pretty easy to trigger by doing something like, e.g.
-------
-- attempt to create a ~500M string
select repeat('X', 500000000);
-------
--
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
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 using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: mail@joeconway.com, kaido.vaikla@gmail.com
Subject: Re: Invoke OOM killer
In-Reply-To: <47cb8d14-7288-945e-19d1-655b8117960e@joeconway.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