pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedInvoke OOM killer
4+ messages / 4 participants
[nested] [flat]
* Invoke OOM killer
@ 2023-07-06 16:27 kaido vaikla <kaido.vaikla@gmail.com>
0 siblings, 3 replies; 4+ messages in thread
From: kaido vaikla @ 2023-07-06 16:27 UTC (permalink / raw)
To: pgsql-admin
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
br
Kaido
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Invoke OOM killer
@ 2023-07-06 16:40 Ron <ronljohnsonjr@gmail.com>
parent: kaido vaikla <kaido.vaikla@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Ron @ 2023-07-06 16:40 UTC (permalink / raw)
To: pgsql-admin@lists.postgresql.org
On 7/6/23 11: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
https://www.percona.com/blog/out-of-memory-killer-or-savior/
I'd run "wapoff -a", set vm.overcommit_memory=2, and then run a simple C
program that mallocs a /lot/ of memory, mlocks it and then fills it with FF
bits.
--
Born in Arizona, moved to Babylonia.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Invoke OOM killer
@ 2023-07-06 17:12 Joe Conway <mail@joeconway.com>
parent: kaido vaikla <kaido.vaikla@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Joe Conway @ 2023-07-06 17:12 UTC (permalink / raw)
To: kaido vaikla <kaido.vaikla@gmail.com>; pgsql-admin
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Invoke OOM killer
@ 2023-07-07 16:07 Jeff Janes <jeff.janes@gmail.com>
parent: kaido vaikla <kaido.vaikla@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Janes @ 2023-07-07 16:07 UTC (permalink / raw)
To: kaido vaikla <kaido.vaikla@gmail.com>; +Cc: pgsql-admin
On Thu, Jul 6, 2023 at 12:27 PM kaido vaikla <kaido.vaikla@gmail.com> wrote:
> Hi,
>
> How to invoke OOM killer for pg process?
> Some easy "hack" for test purpose.
>
For most purposes, you can just pick a backend process ID, and send it a
`kill -9`. From the PostgreSQL perspective, that is just what the OOM
killer does.
If it needs to happen 'naturally', you could do something like:
set work_mem=50GB;
select * from generate_series(1,100000000) order by random();
Where the numbers may need to be adjusted based on your RAM.
Cheers,
Jeff
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2023-07-07 16:07 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 16:27 Invoke OOM killer kaido vaikla <kaido.vaikla@gmail.com>
2023-07-06 16:40 ` Ron <ronljohnsonjr@gmail.com>
2023-07-06 17:12 ` Joe Conway <mail@joeconway.com>
2023-07-07 16:07 ` Jeff Janes <jeff.janes@gmail.com>
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