Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qrHzB-003Xay-CH for pgsql-admin@arkaria.postgresql.org; Fri, 13 Oct 2023 13:13:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qrHz9-000b4J-5F for pgsql-admin@arkaria.postgresql.org; Fri, 13 Oct 2023 13:13:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qrHz8-000b2N-1E for pgsql-admin@lists.postgresql.org; Fri, 13 Oct 2023 13:13:46 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qrHz3-000Liq-Il for pgsql-admin@lists.postgresql.org; Fri, 13 Oct 2023 13:13:45 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40776b1ff73so739175e9.2 for ; Fri, 13 Oct 2023 06:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697202820; x=1697807620; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:subject:cc:to:from:date :sender:message-id:from:to:cc:subject:date:message-id:reply-to; bh=lVN9TXL5tB6aTDdtZ/lvM8cmu+7s7S4z6Zvd9zCpcrw=; b=U9jVHSKyUjT/KuQn06XWf6pcpwOH5nXZJ8epiPFoWwA1sMou4AKixiSFzKTOgVWEMO xtK6R+zH3pT2inhYQLugB4zt9yVkMXChngOSFBbXmEZn9lPGto+ozYfqmJS5OLYKndho TEhlJFYpWa94F1DjewNRKrZTlXJv0FUM8I1ZVq5PGvkSRMomen+jh0R8VsMmsp5ki7VA gKHVFdjn+qB+dmrHqUQFTsaZOhZ0N+8hYn4t04kE8gDQ1MWqXdKXL5ueWGto9MnWTorU E65Porx7UQSeKfvBj2QyzgM+GM2Ol1TsP/Rk2XORbU0/+ykDiZklqvDRlaQ37ncJuwF5 g7EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697202820; x=1697807620; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:subject:cc:to:from:date :sender:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lVN9TXL5tB6aTDdtZ/lvM8cmu+7s7S4z6Zvd9zCpcrw=; b=tNoVApAYzY4AKqfM5cmRp6sP2m7olSH8ZOjqO3qDTxc/Kwh/hELjNJo+QeNE9bAHYl pPyVkhJb80zE6EyEjLNTY8P2ZTgac05jqBU1T9Em/Q5OskkriiW7Or33q8m1JcOx24cO V2fPv9hgzPXvJcnbIQnLB7YByWlfJmAT8SArwKkAhMaMsoFzbBHrpr32tfNlqZfGod2f p1VofWrgaogXIRIgFAKf7UpjcR3SUS/N3E1v8KQYHhCWDAKYMfg/6yB78ir8SUDMRDy7 pinhGdzZ8NsITpQtqCT62NcP2RWVdM/VpEgdopvzJhl6cg9KO6kWJWZsgh+CTuU8d6cb Ah3Q== X-Gm-Message-State: AOJu0Yxdyh7MWquYOs7GECdrLcYGApSvdJ1pjRn+EpINfHvBLvTp4tl/ C/Aq5eT7PE4MTmXe4XMmlQjVHOxVnYM= X-Google-Smtp-Source: AGHT+IHePE1sf1NpkA70Rt7R2hhQl48RiKbIdjugO5dloNZ9NfQe3iZ+/P7sTU44Z3HID5dnhryMhw== X-Received: by 2002:a1c:741a:0:b0:406:3977:eccd with SMTP id p26-20020a1c741a000000b004063977eccdmr23022415wmc.33.1697202819991; Fri, 13 Oct 2023 06:13:39 -0700 (PDT) Received: from lightning.caipicrew.dd-dns.de ([2001:a61:34cf:1001:f11c:3b32:31b7:711]) by smtp.gmail.com with ESMTPSA id n38-20020a05600c502600b003fefaf299b6sm94242wmr.38.2023.10.13.06.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 06:13:39 -0700 (PDT) Message-ID: <65294283.050a0220.4c49b.0ac4@mx.google.com> X-Google-Original-Message-ID: <20231013131338.GN27104@caipicrew.dd-dns.de;lightning.caipicrew.dd-dns.de> Sender: Michael Banck Received: from mbanck by lightning.caipicrew.dd-dns.de with local (Exim 4.92) (envelope-from ) id 1qrHz1-0001Dx-0F; Fri, 13 Oct 2023 15:13:39 +0200 Date: Fri, 13 Oct 2023 15:13:38 +0200 From: Michael Banck To: Jean-Christophe Boggio Cc: pgsql-admin@lists.postgresql.org Subject: Re: One PG process eating more than 40GB of RAM and getting killed by OOM References: <1018f9c0-9d14-4146-b7e9-24c48ea29e1d@thefreecat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1018f9c0-9d14-4146-b7e9-24c48ea29e1d@thefreecat.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Fri, Oct 13, 2023 at 03:06:57PM +0200, Jean-Christophe Boggio wrote: > On my dev laptop, I have ~40GB free RAM. When launching a heavy calculation > in PostgreSQL (within a stored procedure), it consumes as much memory as is > available and then gets killed by OOM. There is only one connected session. > > I have the following settings, which look reasonable (to me): > > shared_buffers = 512MB                  # min 128kB That's not a lot. > work_mem = 1GB                          # min 64kB On the other hand, that's a lot. So if that query is run in parallel and has a lot of different things it does, it might use work_mem several times over, resulting in a lot of used memory. So first thing to try would be to lower work_mem to someting much lower like 64MB or 128MB. > This is PostgreSQL 14.7 running on Ubuntu 23.04 The other thing you can try is to see whether turning jit off (or just jit_inline_above_cost = -1) is helping. Michael