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 1jQSOH-0005jC-Hk for pgsql-admin@arkaria.postgresql.org; Mon, 20 Apr 2020 09:06:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQSOG-00020M-9B for pgsql-admin@arkaria.postgresql.org; Mon, 20 Apr 2020 09:06:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQSOG-00020E-1i for pgsql-admin@lists.postgresql.org; Mon, 20 Apr 2020 09:06:56 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jQSOC-0002xX-Ub for pgsql-admin@postgresql.org; Mon, 20 Apr 2020 09:06:55 +0000 Received: by mail-wm1-x342.google.com with SMTP id u127so9342914wmg.1 for ; Mon, 20 Apr 2020 02:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=ijYS770X0fC904WM05ojVg2ExwqtF0dO5PDgRUWrAyQ=; b=Ab/6296qv928mMwK8t9+hTc2KTZ/Gh/RSuHKUrbsDx3zXwBGC/7Dhlo2y1IvL+dbVY PzyCl7kCaQYH17af4YUggpTF3IN14Oi6660VJxam+e34tFvrO2mQ3wOUExXUrgxhZzEB o+WRHQQDNNwDgaZuD0hZE7/FXdgdqUPahnwdtO22Q1+joNPXsg4nJOCAbItSEGmr5WFG cKp3+ZJ+IyEAgUN8EwdL1DdVouY9x4VHKT/jcKCW8pFU7O1r2kdZQfeoUTPrARts3fHv zUe3QD6z0Mwz1+bPmmEDii1+tpBNVUhLNHuff7J/3fjSx5LHBWSImedyrpzHVUAUYZgF GCCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ijYS770X0fC904WM05ojVg2ExwqtF0dO5PDgRUWrAyQ=; b=J6RXWEsHvYiNwlm6Wl+YP+HrZKigqQe4vjLWYAZXNSeD5Jx8PvUyBIMig7eEDuIIWQ goXofP+3NP3fAbngmEi29AwPlWcuSCxIiMFfOafZr+9nNsx7xNMBRujtPIRR26gf+sUN xhhDTPGDkZgorTkU8wNdpaJBD76U9Dm5IaQusuwJMa228jPm9ylqcM28GIesD6yu1OX9 sHfVL1wQ42OZohgbwkvZlNKCi8I+XzO98NAy80oa4xcgnYoW8hBcmcK8x3MBE79KdgTH ftwfghjRKQWa4+MPyeQ38X4sEbLPC53KTxk96azaQa1DKjvNjLalTk53IFb42q5xxQwI iwLA== X-Gm-Message-State: AGi0PubZtFJF4NcnXjqCHpr1oyrvb4Ewjsk0/eD980mGrvUhexy69WrF IfiCfAfPZ0FDyTU8O+mHhokTNCTz39z+UA== X-Google-Smtp-Source: APiQypJb2l0FM1kyRXZBXi6rDS/74S6Wul7qYxSxdhQoc60mYuzFfaVmZOHJTG+PHnj2k6tN7C6xsQ== X-Received: by 2002:a05:600c:c5:: with SMTP id u5mr3766308wmm.134.1587373611888; Mon, 20 Apr 2020 02:06:51 -0700 (PDT) Received: from dynamic-eoa1xw1q44qdjznxo-pd01.res.v6.highway.a1.net (dynamic-eoa1xw1q44qdjznxo-pd01.res.v6.highway.a1.net. [2001:871:60:9afb:eb30:1de6:8277:4aec]) by smtp.gmail.com with ESMTPSA id a125sm525764wme.3.2020.04.20.02.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 02:06:51 -0700 (PDT) Message-ID: <5193b00d175f2e06a171ba375f1ef723e1700de4.camel@cybertec.at> Subject: Re: checkpoint process use too much memory From: Laurenz Albe To: jian xu , "pgsql-admin@postgresql.org" Date: Mon, 20 Apr 2020 11:06:50 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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//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//limits). Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com