Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRhAj-00028U-Ta for pgsql-general@arkaria.postgresql.org; Wed, 20 Dec 2017 16:24:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRhAi-0007UG-JZ for pgsql-general@arkaria.postgresql.org; Wed, 20 Dec 2017 16:24:44 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eRhAi-0007U5-4L for pgsql-general@lists.postgresql.org; Wed, 20 Dec 2017 16:24:44 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eRhAe-0004e8-Rn for pgsql-general@postgresql.org; Wed, 20 Dec 2017 16:24:42 +0000 Received: by mail-wm0-x22e.google.com with SMTP id g130so16459207wme.0 for ; Wed, 20 Dec 2017 08:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=1n4nFdbhaWhnvn8mQwBD9uxjN9UxojXwfZhku3osQh4=; b=aoSPlySLY7QwYA+CAhD8veq/xOxOoMCkVx3PG8EkxuiavdnT3y8knJAHB5g+S5yuas +1ivWfOYzGgUgv7GK+NFN64NRVZffIsoaEmf43+IOnr5F24wypLRKwiOr/4eL0hukfaL LdAD3O46bPxVm+DktSL6Nm6W2Zrs3g9C8j49MBa3A03EUZcdHZipL1eMdfEszhwsb+t+ B9gSQxptIn658yxc+aCyJLQtDRpIQeH68idiZJdPJXIJcf7MUkkDBHPM/Y3kVK+5wlwj XwSRVvawScW+pi8KhoQuqCeEFutjbG/Sm3Fq9Z2slc5y0JaxK2LWXpvkRn2osAKyCCts WcLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1n4nFdbhaWhnvn8mQwBD9uxjN9UxojXwfZhku3osQh4=; b=EjdEGVwIGe78FHrerZVB4LkKnud582rDA38GUj9eOj3isRZP8Aj1cCfCE9LofIz3I1 T1q71UMNdZ9DUjxZTE7QbYBXRX6hMzi7z3UgkWcQkv7k4NY7yO7WcRH+2Iuo5/hVxLCE j4xpQp0T2VkE8CIul2OJR59ZhpwIOrYNIzxGSLgCrhoyAwGoi/CwUCCi1tKzcra6mZpH Q/y+Q6bsZk8A/1kw3xu8LMZdviq+bA0vuTkEqyTymjZNdtrQ4Gh8Uf6+hBWGKhfuJs/d f02tqeJWvXWbl/v9ZmNdQMUZnO0l5SvN+tpp4cZ5dubFX6Upbhqs9/RPli+DICYHhD4M 6lug== X-Gm-Message-State: AKGB3mJXDXQGvVT6+hk1aAOaD5k5i+h8CysCwIeTT6HptWgk16YFl+nE fWRYVBVj/4tvVoOMgKbk4/gs7+D1hk3pZCJA/ZOpAc/PlvqQSfexx7jPUvbB7MicDz4RIvtVV0H ZRLBgh0zb6eNVR8CCgHzUh1R6W5iGsr90nJVbLWZAt45DKdVPLxR3VQivLILovX2Oo9gXjjRT18 oVdLFVamKL X-Google-Smtp-Source: ACJfBovmDNCXCk9SEFz7FqK1spVhVmXoAx6EDDAu8YhtWo3X8Y9wxm9EeGrDX//cfM/T7TFAQI+Ppg== X-Received: by 10.80.140.237 with SMTP id r42mr6050510edr.299.1513787077863; Wed, 20 Dec 2017 08:24:37 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id z1sm15944334edz.17.2017.12.20.08.24.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 08:24:37 -0800 (PST) Subject: Re: postgresql 9.5 has ocuuered OOM To: mark , pgsql-general@postgresql.org References: <2fd6f5eb.10a25.160747856ec.Coremail.pgroad@163.com> From: Tomas Vondra Message-ID: <74cbd04b-88b6-f991-e253-7805e3ac7128@2ndquadrant.com> Date: Wed, 20 Dec 2017 17:24:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <2fd6f5eb.10a25.160747856ec.Coremail.pgroad@163.com> Content-Type: text/plain; charset=gbk Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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