pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedpostgresql 9.5 has ocuuered OOM
9+ messages / 6 participants
[nested] [flat]
* postgresql 9.5 has ocuuered OOM
@ 2017-12-20 15:08 mark <pgroad@163.com>
0 siblings, 3 replies; 9+ messages in thread
From: mark @ 2017-12-20 15:08 UTC (permalink / raw)
To: pgsql-general
I have set shared_buffers is 1/4 of memory.
work_mem is 2% of memory.
max_connections is 50.
momery size is 16GB.
postgresql process used over 70% of memory and occuered OOM.
what should I do to deal with this problem?
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 16:24 Tomas Vondra <tomas.vondra@2ndquadrant.com>
parent: mark <pgroad@163.com>
2 siblings, 2 replies; 9+ messages in thread
From: Tomas Vondra @ 2017-12-20 16:24 UTC (permalink / raw)
To: mark <pgroad@163.com>; pgsql-general
On 12/20/2017 04:08 PM, mark wrote:
> I have set shared_buffers is 1/4 of memory.
> work_mem is 2% of memory.
> max_connections is 50.
That means if you have all 50 connections active, they may easily
consume 100% of memory, because 50 * 2 is 100. It's even easier if the
connections are executing complex queries, because each query may use
multiple work_mem buffers. So 2% seems a bit too high.
> momery size is 16GB.
> postgresql process used over 70% of memory and occuered OOM.
So, did a single process use 70% of memory, or all postgres processes
combined?
If just a single process, it might be a poor plan choice (e.g. hash
aggregate may easily cause that).
If all processes combined, then perhaps it's due to work_mem being too high.
> what should I do to deal with this problem?
>
Hard to say, until you provide enough information.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 16:25 Andreas Kretschmer <andreas@a-kretschmer.de>
parent: mark <pgroad@163.com>
2 siblings, 1 reply; 9+ messages in thread
From: Andreas Kretschmer @ 2017-12-20 16:25 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 20.12.2017 um 16:08 schrieb mark:
> postgresql process used over 70% of memory and occuered OOM.
> what should I do to deal with this problem?
https://www.postgresql.org/docs/current/static/kernel-resources.html
18.4.4. Linux Memory Overcommit
Regards, Andreas
--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 16:44 Uwe <uwe@oss4u.com>
parent: mark <pgroad@163.com>
2 siblings, 1 reply; 9+ messages in thread
From: Uwe @ 2017-12-20 16:44 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org; +Cc: mark <pgroad@163.com>
On Wednesday, December 20, 2017 11:08:51 PM PST mark wrote:
> I have set shared_buffers is 1/4 of memory.
> work_mem is 2% of memory.
> max_connections is 50.
> momery size is 16GB.
> postgresql process used over 70% of memory and occuered OOM.
> what should I do to deal with this problem?
IIRC work_mem is a PER CONNECTION setting, that means every connection can use
2% of your total memory. I'd try setting work_mem to something like 16MB or
32MB and see if the queries still execute properly. You want to set work_mem
as high as needed to allow proper query execution but as low as possible to
avoid running out of memory.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 16:59 David G. Johnston <david.g.johnston@gmail.com>
parent: Uwe <uwe@oss4u.com>
0 siblings, 1 reply; 9+ messages in thread
From: David G. Johnston @ 2017-12-20 16:59 UTC (permalink / raw)
To: Uwe <uwe@oss4u.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>; mark <pgroad@163.com>
On Wed, Dec 20, 2017 at 9:44 AM, Uwe <uwe@oss4u.com> wrote:
> IIRC work_mem is a PER CONNECTION setting,
>
The docs for this setting clearly state that a single connection/session
can itself use multiple times this values for a single query.
https://www.postgresql.org/docs/10/static/runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMOR...
David J.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 17:01 Uwe <uwe@oss4u.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Uwe @ 2017-12-20 17:01 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>; mark <pgroad@163.com>
On Wednesday, December 20, 2017 9:59:24 AM PST David G. Johnston wrote:
> On Wed, Dec 20, 2017 at 9:44 AM, Uwe <uwe@oss4u.com> wrote:
> > IIRC work_mem is a PER CONNECTION setting,
>
> The docs for this setting clearly state that a single connection/session
> can itself use multiple times this values for a single query.
>
> https://www.postgresql.org/docs/10/static/runtime-config-resource.html#RUNTI
> ME-CONFIG-RESOURCE-MEMORY
>
So even worse for the OP. No wonder he runs out of memory.
Thanks for the correction.
Uwe
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 17:11 Scott Marlowe <scott.marlowe@gmail.com>
parent: Andreas Kretschmer <andreas@a-kretschmer.de>
0 siblings, 0 replies; 9+ messages in thread
From: Scott Marlowe @ 2017-12-20 17:11 UTC (permalink / raw)
To: Andreas Kretschmer <andreas@a-kretschmer.de>; +Cc: pgsql-general@lists.postgresql.org
On Wed, Dec 20, 2017 at 9:25 AM, Andreas Kretschmer
<andreas@a-kretschmer.de> wrote:
>
>
> Am 20.12.2017 um 16:08 schrieb mark:
>>
>> postgresql process used over 70% of memory and occuered OOM.
>> what should I do to deal with this problem?
>
>
> https://www.postgresql.org/docs/current/static/kernel-resources.html
> 18.4.4. Linux Memory Overcommit
More specifically:
https://www.postgresql.org/docs/current/static/kernel-resources.html#LINUX-MEMORY-OVERCOMMIT
To reiterate the basic message there, at no time should the OS think
that killing big processes is OK. It is NOT. At no time should your OS
be terminating big processes all on its own.
Also it's far better to starve your work_mem and keep all the
processes running than to ever run any out of memory. But if one does
run out of memory it should only cause a problem for that one process,
not the backend writer etc.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-20 18:15 Andreas Kretschmer <andreas@a-kretschmer.de>
parent: Tomas Vondra <tomas.vondra@2ndquadrant.com>
1 sibling, 0 replies; 9+ messages in thread
From: Andreas Kretschmer @ 2017-12-20 18:15 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 20.12.2017 um 17:24 schrieb Tomas Vondra:
> That means if you have all 50 connections active, they may easily
> consume 100% of memory, because 50 * 2 is 100. It's even easier if the
> connections are executing complex queries, because each query may use
> multiple work_mem buffers. So 2% seems a bit too high.
Nice hint! You are right.
Regards, Andreas
--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re:Re: postgresql 9.5 has ocuuered OOM
@ 2017-12-21 00:37 mark <pgroad@163.com>
parent: Tomas Vondra <tomas.vondra@2ndquadrant.com>
1 sibling, 0 replies; 9+ messages in thread
From: mark @ 2017-12-21 00:37 UTC (permalink / raw)
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>; +Cc: pgsql-general
Hi Tomas,Uwe,David G
Thanks for your reply.
>So, did a single process use 70% of memory, or all postgres processes
>combined?
all postgres processes use over 70% of memory.
>If just a single process, it might be a poor plan choice (e.g. hash
>aggregate may easily cause that).
because delete clause used a lot of memory .
delete clause is below:
DELETE FROM test WHERE testid in (select r_id from test1 where p_id_id in ( select re_id from ap_en where link = $1))
delete from test where test1_id = $1 AND id = $2
because delete clause is using select condition. maybe It make memory useage high.
if I decrease the work_mem size,It will affect delete clause execution efficiency,
I want the session unit to set work_mem size.
the OS level (cgconfig) to set all postgres processes memory usage.
How about this setting ?
Regards,
Mark
At 2017-12-21 00:24:35, "Tomas Vondra" <tomas.vondra@2ndquadrant.com> wrote:
>On 12/20/2017 04:08 PM, mark wrote:
>> I have set shared_buffers is 1/4 of memory.
>> work_mem is 2% of memory.
>> max_connections is 50.
>
>That means if you have all 50 connections active, they may easily
>consume 100% of memory, because 50 * 2 is 100. It's even easier if the
>connections are executing complex queries, because each query may use
>multiple work_mem buffers. So 2% seems a bit too high.
>
>> momery size is 16GB.
>> postgresql process used over 70% of memory and occuered OOM.
>
>So, did a single process use 70% of memory, or all postgres processes
>combined?
>
>If just a single process, it might be a poor plan choice (e.g. hash
>aggregate may easily cause that).
>
>If all processes combined, then perhaps it's due to work_mem being too high.
>
>> what should I do to deal with this problem?
>>
>
>Hard to say, until you provide enough information.
>
>regards
>
>--
>Tomas Vondra http://www.2ndQuadrant.com
>PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2017-12-21 00:37 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-12-20 15:08 postgresql 9.5 has ocuuered OOM mark <pgroad@163.com>
2017-12-20 16:24 ` Tomas Vondra <tomas.vondra@2ndquadrant.com>
2017-12-20 18:15 ` Andreas Kretschmer <andreas@a-kretschmer.de>
2017-12-21 00:37 ` mark <pgroad@163.com>
2017-12-20 16:25 ` Andreas Kretschmer <andreas@a-kretschmer.de>
2017-12-20 17:11 ` Scott Marlowe <scott.marlowe@gmail.com>
2017-12-20 16:44 ` Uwe <uwe@oss4u.com>
2017-12-20 16:59 ` David G. Johnston <david.g.johnston@gmail.com>
2017-12-20 17:01 ` Uwe <uwe@oss4u.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