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 1pRxid-0008Bx-2s for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Feb 2023 15:59:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pRxib-0001GL-LJ for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Feb 2023 15:59:45 +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 1pRxia-0001GA-W2 for pgsql-bugs@lists.postgresql.org; Tue, 14 Feb 2023 15:59:45 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pRxiY-0007lO-EA for pgsql-bugs@lists.postgresql.org; Tue, 14 Feb 2023 15:59:43 +0000 Received: by mail-qt1-x82f.google.com with SMTP id g8so17926131qtq.13 for ; Tue, 14 Feb 2023 07:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joeconway.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=HqyBMNccjhNd9PhZyYAP+OkyxI0J4GKTHUGMrPSsSYU=; b=Oha/f8PH2ZDZAxFd/1P2SAGsvNR8hhjP0npE5H/doizRhmtQ7sj3dSpmvkKcmvOyNB Hr3paVfz0ClQophlxwq5lReepcwzdzfG8Z99d3EVTViguOU/OE+xdkXxz5vZQm9CoN/l /4OrvHYy/YUxR2NlTBVNFHrBqXr4xaH2GW9AKoLQPFkPc9flszJ9iAovM6Il1+SX+pjw 6OPXiPZwN5ez1+YAUfLpYiHd/6q7q7HbjgntQlEV18E+qxTTzhlcbUo8ozVrG10qMGfP tyFJA667nIkddVkNklA6vomfEdy6M64HkclLJWaK43oNRn+5i7cd/Nd1gqsEji6dUt/7 MIww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HqyBMNccjhNd9PhZyYAP+OkyxI0J4GKTHUGMrPSsSYU=; b=28RVaIiLNq4HENe8RemwRzAXGnGjGkONxZ5/gU0RpulI8iDa+7Kl1kXmLnHtExKHdv neMfU1Zpvc5lYgtwnZCVFfkgUdJx06psqKCHh2WcCmPW89J8NdQ2ADkO5AyitHBWxg6v 6iaX3hw3kup31jkRBGCkKQZqB1KnC37VAKv55QwWm15hDCaHXJOVLiqPCuQi/9hBJNH7 JyGc2MKEQyMyBDxz5J6KWWhWV8ZBC1M8xnK2Lj1cV4EoUMxKQI0w2Pjuv/YxdAQP6c6e LgAE1CFOdabVpBU3o6AkgXN17d99DxMhrux2s/YzsUgYCJY6dX0UC2xq4x2SGGLHQbEC 3e0A== X-Gm-Message-State: AO0yUKXilu2h6kwMLI2NKJls9Y4WhXq2iZ2weusLDGEK3urjHXG/V0fk +kxJU8KZQOMReclyXgSNU43NyQ== X-Google-Smtp-Source: AK7set+dqNUT6GCPJK4X+/i0t1gjmxpz6FqgaKIo2gYll0/nEkIcr/jWi55wAWLdGzLoguCWP1kV4w== X-Received: by 2002:a05:622a:1388:b0:3ba:1d8d:f6eb with SMTP id o8-20020a05622a138800b003ba1d8df6ebmr4954907qtk.58.1676390381416; Tue, 14 Feb 2023 07:59:41 -0800 (PST) Received: from [192.168.4.41] (162-239-31-113.lightspeed.dybhfl.sbcglobal.net. [162.239.31.113]) by smtp.gmail.com with ESMTPSA id r142-20020a37a894000000b00729a26e836esm12133194qke.84.2023.02.14.07.59.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 07:59:41 -0800 (PST) Message-ID: <1975c07f-82a0-3503-e221-211b43878467@joeconway.com> Date: Tue, 14 Feb 2023 10:59:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: BUG #17793: Query with large number of joins crashes PostgreSQL Content-Language: en-US To: Tom Lane , Francisco Olarte Cc: tom@quist.de, pgsql-bugs@lists.postgresql.org References: <17793-21fa598adbc21118@postgresql.org> <1682145.1676386040@sss.pgh.pa.us> From: Joe Conway In-Reply-To: <1682145.1676386040@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/14/23 09:47, Tom Lane wrote: > Francisco Olarte writes: >> On Tue, 14 Feb 2023 at 11:29, PG Bug reporting form >> wrote: >>> It looks like the OS is killing the process due to running OOM, which is not >>> very surprising when looking at the query. Is this expected, or should PG >>> have guards in place to prevent this from happening? > >> When you run postgres in an environment where someone ( OOM killer ) >> can K9 it, protection is hard. IIRC OOM can kill you because ANOTHER >> process touches memory, among other things. > > Yeah. We have no visibility into what the OOM killer will choose to > allow or not allow at any instant. > >> ( I do run DBs in machines w/ overcommit disabled, this prevents it >> from happening, but it is not Pg who prevents it ). > > If overcommit-disabled doesn't seem practical, another idea that's > been recommended is to start the postmaster under a "ulimit -v" > setting chosen to cause plain ENOMEM failures before the OOM > killer kicks in. Given: > It looks like the OS is killing the process due to running OOM ... > I could reproduce it using a fresh docker container of the image > "postgres:13.10". I gather the OP is running Postgres in a container. If so, and if they have a memory.limit set (also assuming cgroup v1, otherwise memory.max for cgroup v2), disabling overcommit at the host level will not prevent an OOM kill when the cgroup exceeds memory.limit -- Joe Conway PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com