Re: checkpoint process use too much memory - Mailing list pgsql-admin

From jian xu
Subject Re: checkpoint process use too much memory
Date
Msg-id MN2PR05MB6832AA29B8D72FCA59D29E19A1D40@MN2PR05MB6832.namprd05.prod.outlook.com
Whole thread Raw
In response to Re: checkpoint process use too much memory  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: checkpoint process use too much memory  (Scott Ribe <scott_ribe@elevated-dev.com>)
List pgsql-admin
Thanks Laurenz. that' very helpful!
when we saw this issue, we restarted the pg service. so we lost the process info right now. 
However, we saw the server run out of the memory at that time, the free memory size was very low.
As you said, if this was a red herring, how could pg use so much memory? 
the shared_buffer is 4GB, there were 200 user connections , the work_mem is 128MB, so they could use mostly 25GB memory,
so shared_buffer(4GB) + user connections(25GB) = 29GB. why did htop RES show 171GB?
I am also wondering if this issue recurs, what  information shall I collect, how to figure out which part of pg use most of the memory?
any hint or tool is available?
thanks for your help
James


From: Laurenz Albe <laurenz.albe@cybertec.at>
Sent: Monday, April 20, 2020 5:06
To: jian xu <jamesxu@outlook.com>; pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: checkpoint process use too much memory
 
On Sun, 2020-04-19 at 13:56 +0000, jian xu wrote:
> My pg version is 10.3, last week my user got error :
>
> OperationalError: (psycopg2.OperationalError) could not fork new process for connection: Cannot allocate memory
> could not fork new process for connection: Cannot allocate memory

> when I checked the database, I found checkpoint process used too much memory, htop showed
> VIRT: 171GB
> RES: 171GB
> SHR:4176MB
> MEM%: 70%
> Command: Posgres: checkpointer process

> The postgresq.conf is
> Shared_buffers = 4GB
> Work_mem = 128MB
> Maintenance_work_mem = 2GB
> Wal_level = replica
> Wal_buffer = 16MB
> Checkpoint_completion_target = 0.7

> How can I troubleshooting this error? Why checkpoint process used so much memory? it sounds like a memory leak issue in checkpointer process.

That is probably a red herring, because the memory reported for the checkpointer
is shared memory that all PostgreSQL processes access.  Utilities like "ps"
show shared memory for all processes that access it, so they don't show the truth.

A better value would be the sum of all the Private_* entries in /proc/<pid>/smaps,
which shows only the private memory.

Not that the error does not necessarily mean that you are out of memory.
It might as well indicate that you are out of open file descriptors for the user
(see /proc/<pid>/limits).

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

pgsql-admin by date:

Previous
From: Marlene Villanueva
Date:
Subject: Re: Exporting TBs of data in Oracle schema/database into CSV formatto migrate into PostgreSQL
Next
From: Scott Ribe
Date:
Subject: Re: checkpoint process use too much memory