Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKwAg-0007Jx-8O for pgsql-admin@arkaria.postgresql.org; Wed, 23 Sep 2020 04:14:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kKwAf-00043z-5d for pgsql-admin@arkaria.postgresql.org; Wed, 23 Sep 2020 04:14:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kKwAe-00043q-M3 for pgsql-admin@lists.postgresql.org; Wed, 23 Sep 2020 04:14:20 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kKwAa-0003US-Kb for pgsql-admin@lists.postgresql.org; Wed, 23 Sep 2020 04:14:19 +0000 Received: by mail-pg1-x541.google.com with SMTP id o25so8628060pgm.0 for ; Tue, 22 Sep 2020 21:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=50R2j8i31qw+DIcvNk8F9aVrBPM28hd7khnSRiBPgWw=; b=eQdEKLMQaK4Cs+nQzH8PSeVLhPmRz3gAXcWMJ7qU1fpGDhtpJFzgNiVDbtTocVZ52y rMQ0G+16GhSo+xN8jIMsOOKB0cRtcrlOG2osHTQMRjs3KJwfytseb5NuS80Hpdl5fIKt 8HhyCoieSsl9rLeLKo9fAzihn4TwHrQn8mRrKcm9jsh735NdL+A1t9/cXynwJEREwnoY 8B4aHBjR/LsHEnU4eKp60gHLNavXtJ76rxRpbjYWfIELuzoGL7d55StgdAEt5rtk5D49 fxbs5v9ErfFMCAV3T/EhN1eM/U42lCgYazOCDT7aT7DSOfzuNgCcRTCAsinyTS8BbLf5 ILvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=50R2j8i31qw+DIcvNk8F9aVrBPM28hd7khnSRiBPgWw=; b=jlBoiAvUnFHLXzVps+Iyp+5h3PXogH4v6pbpGOrMFOYb8xjYRoeCSNznqjiWaAtfqa XA14/iPjOnlHhNCqs0whJZsDhWzwAUy4+yWk3u27ZrPuE0hP2iE/JE3m8MEk7ccTRrf7 kBB35x4ELDO5QWILj25fpnCgG3dVJ/jVCMplKTH5GI54Su1ypV5EoTedGe6rWHx+LIBw EEeTb4ZdTtGcp0qK6vetsB7gR/yKdRvIuLKxzV0OjH8IeXc0Ll50nGiKhop7CjNutbi7 oBC7fO0JgntMDu5flEVGFycDgR1xoXZXeyCMc1hpLGKbD3v0jx7T3iyQ6zBoB5m0fqSj ad2Q== X-Gm-Message-State: AOAM532Zl9fjIrdEigILH61zRp158j+JRRGMz9dHeDspPIn09gmHFkh3 TjvOCodpLmuPG9fpjUX3g1vtmKoCwOw= X-Google-Smtp-Source: ABdhPJx4UONp2+QFO2xA2Axf95kJFLkzugX7z6cMb7jAixwmKiBSSoSIgLtCXRb3a2SIl5XWFuRNIQ== X-Received: by 2002:a63:1402:: with SMTP id u2mr5762687pgl.400.1600834455434; Tue, 22 Sep 2020 21:14:15 -0700 (PDT) Received: from 192-168-1-114.tpgi.com.au ([203.63.94.51]) by smtp.gmail.com with ESMTPSA id gn24sm3476638pjb.8.2020.09.22.21.14.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 21:14:15 -0700 (PDT) From: Hannah Huang Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_93F2EA81-3669-465E-B30C-C071E72D0E0E" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: Cannot allocate memory Date: Wed, 23 Sep 2020 14:14:10 +1000 In-Reply-To: Cc: pgsql-admin@lists.postgresql.org To: mjoigny@neteven.com References: <2d20d632-f9ee-9606-f674-18d19b1790c0@neteven.com> <6DA04674-987B-490A-AEE6-DB8542905CC4@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_93F2EA81-3669-465E-B30C-C071E72D0E0E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 23 Sep 2020, at 12:59 am, JOIGNY Michael @Neteven = wrote: >=20 > Hi Hannah, >=20 > Thanks for your feedback.=20 >=20 > Here are the CPU / IO graphs over the same period.=20 >=20 > You will find on the graphs the annotation which specifies the moment = of the migration. >=20 >=20 > >=20 > >=20 > >=20 > >=20 >=20 >=20 > Le 22/09/2020 =C3=A0 15:10, Hannah Huang a =C3=A9crit : >>=20 >>=20 >>> On 22 Sep 2020, at 6:20 pm, JOIGNY Michael @Neteven = > wrote: >>>=20 >>> Hi, >>>=20 >>> I would like to come back to you about my memory problem on postgres = 12. >>>=20 >>> We had the same configuration under postgres 11.8, we disabled JIT = (enabled by default under postgres 12) for segfault problems.=20 >>>=20 >>> To illustrate the change in memory behavior, here is a screenshot = before / after migration :=20 >>>=20 >>> >>>=20 >>>=20 >>> Do you have any idea what could change the behavior in this way? = another parameter enabled by default under postgres 12 like JIT? >>>=20 >>> Regards. >>>=20 >>> Le 18/09/2020 =C3=A0 12:03, JOIGNY Michael @Neteven a =C3=A9crit : >>>> Hi Community,=20 >>>>=20 >>>> I'm asking for your lights because i'm having memory problems with = postgres. >>>>=20 >>>> Examples of logs : >>>>=20 >>>> FATAL: could not fork new process for connection: Cannot allocate = memory could not fork new process for connection: Cannot allocate memory >>>> out of memory DETAIL: Failed on request of size 32800 in memory = context "HashBatchContext". >>>> out of memory DETAIL Failed on request of size 288 in memory = context "CacheMemoryContext". >>>>=20 >>>>=20 >>>> We use postgresql (primary/standby) with pgbouncer as a pooler, and = repmgr as replication manager. >>>>=20 >>>> We have ~ 2000 connections at the same time with ~ 20/30 are = active. (we need to set a high number of connexion on postgres, because = our app uses a lot of different users, and each user on each app server = needs multiple and constant connexions). >>>>=20 >>>> Here is my configuration :=20 >>>>=20 >>>> system :=20 >>>>=20 >>>> Debian : 9.13 >>>> Memory : 380 Go >>>> Postgres : 12.4-1.pgdg90+1 >>>> Pgbouncer : 1.14 >>>> kernel.shmmax =3D 202591600640 >>>> kernel.shmall =3D 49460840 >>>> postgres :=20 >>>>=20 >>>> dynamic_shared_memory_type =3D posix # the default is the first = option >>>> max_connections =3D 2600 # (change requires restart) >>>> work_mem =3D 96MB # min 64kB >>>> maintenance_work_mem =3D 8GB # min 1MB >>>> shared_buffers =3D 64GB # min 128kB >>>> temp_buffers =3D 32MB # min 800kB >>>> wal_buffers =3D 16MB # min 32kB, -1 sets based on = shared_buffers >>>> effective_cache_size =3D 270GB >>>>=20 >>>> pgbouncer :=20 >>>>=20 >>>> max_client_conn =3D 6000 >>>> default_pool_size =3D 2590 >>>> reserve_pool_size =3D 5 >>>> pool_mode =3D session >>>>=20 >>>> Do you think that our parameters are not correct compared to our = configuration? Do you have an idea ? >>>>=20 >>>> Best regards. >>>>=20 >>>> Michael. >>>>=20 >> System settings:=20 >> After 9.2, PostgreSQL switched to POSIX shared memory. So now it = requires fewer bytes of System V shared memory.=20 >>=20 >> You don=E2=80=99t need to configure SHMMAX to that high value which = is ~188GB, same as SHMALL, I would set them back to default value.=20 >>=20 >> But, from the second email you sent it seems like an issue related to = the version upgrade (from 11 to 12). So I don=E2=80=99t think you should = change OS parameters at this moment. I would suggest you provide more = stats on CPU (system, user, wa,ni) and disk IO - before and after.=20 >>=20 >> Thanks, Hannah I can see: CPU stats: CPU it spends more time on user job and the wait time on IO = decreases, time spent on kernal space is about same as before.=20 IO stats: read drops dramatically, write slightly increases. This = explains why CPU wait on IO decreases. I would like to know how is the performance of application queries. For = example, the before and after execution time of the most time consuming = queries. Are they still about the same? Do you have any database = performance analytics tools installed? I used to use pgbadger to = analyze database logs which would show me the past performance = statistics of the database. We now have an understanding about how the = OS performance looks like. It would be good to have a general picture = of the database performance from the db layer. Thanks,=20 Hannah --Apple-Mail=_93F2EA81-3669-465E-B30C-C071E72D0E0E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 23 Sep 2020, at 12:59 am, JOIGNY Michael @Neteven <mjoigny@neteven.com>= wrote:

=20 =20

Hi Hannah,

Thanks for = your feedback.

Here are the CPU / IO graphs over the same period. =

You will find on the graphs the annotation which specifies the moment of the migration.


<cpu.png>

<io_requests.png>

<io_bytes.png>=

<io_time.png><= br class=3D"">

Le 22/09/2020 =C3=A0 15:10, Hannah = Huang a =C3=A9crit :


On 22 Sep 2020, at 6:20 pm, JOIGNY Michael @Neteven <mjoigny@neteven.com> wrote:

Hi,

I would = like to come back to you about my memory problem on postgres 12.

We had the same configuration under postgres 11.8, we disabled JIT (enabled by default under postgres 12) for segfault problems.

To illustrate the change in memory behavior, here is a screenshot before / after migration :

<memory.png>


Do you have any idea what could change = the behavior in this way? another parameter enabled by default under postgres 12 like JIT?

Regards.

Le 18/09/2020 =C3=A0 12:03, = JOIGNY Michael @Neteven a =C3=A9crit :

Hi = Community,

I'm asking for your lights because i'm having memory problems with postgres.

Examples of logs :

FATAL: could not fork = new process for connection: Cannot allocate memory could not fork new process for connection: Cannot allocate memory
out of memory  DETAIL:  Failed on request = of size 32800 in memory context "HashBatchContext".
out of memory DETAIL Failed on request of size 288 in memory context "CacheMemoryContext".
=


We use postgresql (primary/standby) with pgbouncer as a pooler, and repmgr as replication manager.

We have ~ 2000 connections at the same time with ~ 20/30 are active. (we need to set a high number of connexion on postgres, because our app uses a lot of different users, and each user on each app server needs multiple and constant connexions).

Here is my configuration :

system :

Debian : 9.13
Memory : 380 Go
Postgres : 12.4-1.pgdg90+1
Pgbouncer : 1.14
kernel.shmmax =3D 202591600640
kernel.shmall =3D 49460840

postgres :

dynamic_shared_memory_type =3D = posix    # the default is the first option
max_connections =3D 2600    =         # (change requires restart)
work_mem =3D 96MB        =         # min 64kB
maintenance_work_mem =3D 8GB    =     # min 1MB
shared_buffers =3D 64GB    =         # min 128kB
temp_buffers =3D 32MB    =         # min 800kB
wal_buffers =3D 16MB    =         # min 32kB, -1 sets based on shared_buffers
effective_cache_size =3D 270GB

pgbouncer :

max_client_conn =3D 6000
default_pool_size =3D 2590
reserve_pool_size =3D 5
pool_mode =3D session

Do you think that our parameters are not correct compared to our configuration? Do you have an idea = ?

Best regards.

Michael.

System = settings: 
After = 9.2, PostgreSQL switched to POSIX shared memory. So now it requires fewer bytes of System V shared memory. 

You = don=E2=80=99t need to configure SHMMAX to that high value which is ~188GB, same as SHMALL, I would set them back to default = value. 

But, = from the second email you sent it seems like an issue related to the version upgrade (from 11 to 12). So I don=E2=80=99t = think you should change OS parameters at this moment. I would suggest you provide more stats on CPU (system, user, wa,ni) and disk IO - before and after. 

Thanks, Hannah

  

I can see:

CPU stats: CPU it spends more time on user job and = the wait time on IO decreases, time spent on kernal space is about same = as before. 
IO stats: read drops dramatically, write = slightly increases. This explains why CPU wait on IO = decreases.

I would like to know how = is the performance of application queries. For example, the before and = after execution time of the most time consuming queries. Are they still = about the same? Do you have any database performance analytics tools = installed?  I used to use pgbadger to analyze  database logs = which would show me the past performance statistics of the database. We = now have an understanding about how the OS performance looks like. =  It would be good to have a general picture of the database = performance from the db layer.

Thanks, 
Hannah




= --Apple-Mail=_93F2EA81-3669-465E-B30C-C071E72D0E0E--