Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecFfz-0006pX-JK for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jan 2018 19:16:39 +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 1ecFfz-0003m7-5u for pgsql-admin@arkaria.postgresql.org; Thu, 18 Jan 2018 19:16:39 +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 1ecFfy-0003lt-RV for pgsql-admin@lists.postgresql.org; Thu, 18 Jan 2018 19:16:38 +0000 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ecFfu-00039E-Nb for pgsql-admin@lists.postgresql.org; Thu, 18 Jan 2018 19:16:37 +0000 Received: by mail-io0-x241.google.com with SMTP id f34so20732335ioi.13 for ; Thu, 18 Jan 2018 11:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=G1THvrhrXFAAJkCxcF1w/tOfGZsqWrovaf4Yq7UYOyw=; b=sFIR/Pfx5Gj259fmViyofeFe5estsfL22G0r+r5y3Q8UZOVUCH62VnYiE3Pen1tyTG KaYl/VA0/WzbbhJr8OsTmmGfYSs1I5Bf4sBeOCP6rK2ZYa5gi3E6ioNvaVjISlGfcpy9 81jdPah2lb2OTGs3YojRRba06Xi1TAauGcKNi/+Jk5wHcBL+DjKV7z0CvV3vvfaJ3M7+ siWyHU2fXFYFudpEtgPYKmlxyAw/Y9L24+LPffPrVQbX39ub8AvS00XU/Df3LtuiS4u5 2bVeVvQ1VzenwyoEdIMLNo5A0FUx0hrdPQPELIzYyLMO6jR1EJmKK0n11NJYUDAfNFWE y7IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G1THvrhrXFAAJkCxcF1w/tOfGZsqWrovaf4Yq7UYOyw=; b=Qo8bc+stbCxWv+XZXumflh+4YssKu6TSAApcME/pQ4CmYojSQ+W/4EK7TIxm7l22GN vCDIh7sOsCE9Qk7T1noicsi+q0Xx/FZRyqzqiXF4ArYi4//46vV8DVGu2TJf66r6jmXN ZMuPgt+Kvu9wVEedKBqW674N8b9Rd9USNSqRlolLijmSuXmM51APvkJ22V3oHLolT/g5 czuJrz0TpDCDHAT4EdVPgjhv+3TzmFY3P30JsGR5biq0f1/nWvOhXz1gMOx0nSykQBEy H5Pt7CyDFiLM5S+IF30vR1sc/a3GCQsXHsgY/s/bPYTqpIpC1cOuxR2NgZt6ZcLp7eWi D5Dw== X-Gm-Message-State: AKGB3mJN9N5Z2hDgA+z9V+WWvkeAA9cBhREqgPJKX2cqy8j/JbleYcfW TYkAWfzne8CNYTSkKH5/izunjHOFGw== X-Google-Smtp-Source: ACJfBouSOqlkiU/aVu9Uk84bwa5lNCPEwHo8TjZgqx4UsRsVhMUdxCE4nOi2OJjeYjyqHBN+3aUDZw== X-Received: by 10.107.34.147 with SMTP id i141mr48197375ioi.184.1516302992179; Thu, 18 Jan 2018 11:16:32 -0800 (PST) Received: from [10.128.4.73] ([216.191.119.186]) by smtp.gmail.com with ESMTPSA id m100sm4111486iod.52.2018.01.18.11.16.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 11:16:31 -0800 (PST) Subject: Re: Abnormally high memory usage/OOM triggered To: Keith Cc: pgsql-admin@lists.postgresql.org References: <4d52fee7-73ba-16a9-9c27-8ae5107ee6ae@gmail.com> <5E0AB8DB-F13B-41BF-843A-FE64FBE9C097@elevated-dev.com> <15a90b55-5151-ce22-16ee-7ff883e5eb97@gmail.com> From: Davlet Panech Message-ID: <8c6d9f34-2a2c-4317-ebbb-ba3ce2cd6a26@gmail.com> Date: Thu, 18 Jan 2018 14:16:32 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/18/2018 12:45 PM, Keith wrote: > > > On Thu, Jan 18, 2018 at 12:13 PM, Davlet Panech > wrote: > > On 1/17/2018 5:57 PM, scott ribe wrote: > > On Jan 17, 2018, at 2:57 PM, Davlet Panech > wrote: > > > Does my configuration look reasonable? I just don't > understand how it could possibly use up 19 GB of memory > based on the configuration below. Is there a memory leak in > there somewhere? > > > It does seem awfully high, but... An update can involve a join > across multiple tables. Or an update can run a trigger which can > cascade. Either of those could result in an "accidental cross > product" join, which can always blow up memory. > > There must be a way to put an upper limit on memory even for such > cases. I was under the impression that parameters such as "work_mem" > serve that purpose, is that not the case? So an "accidental cross > product" join's memory usage is unbounded? It can't be... could > somebody confirm this please? > > Thanks, > D. > > > work_mem isn't really an upper limit on overall memory usage. It's just > an upper limit on how much is used in certain processes before spilling > to disk. A query or group of queries can easily use up all of system > memory if it's complex enough by using multiple instances of work_mem. > This is why work_mem shouldn't be set any higher than necessary. The > wiki explains this better > > https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server > > "This size is applied to each and every sort done by each user, and > complex queries can use multiple working memory sort buffers. Set it to > 50MB, and have 30 users submitting queries, and you are soon using 1.5GB > of real memory. " I understand, but in my case a single server-side postgres process used 19GB, which (excluding shared memory etc) is something like a 100 times what I would expect, even for "complex" queries. > > I would go with Tom's suggestion in this case, though, since that bug > seems to fit the situation described by the patch he found. It's always > important to be running the latest patch release to rule out a bug being > the cause of an issue. OK, so it is likely a memory leak; I just wanted to rule out other explanations. Thanks to all who replied.