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 1pUqVB-0001rO-OC for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Feb 2023 14:53:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pUqVA-0002F8-NC for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Feb 2023 14:53:48 +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 1pUqVA-0002Ez-BL for pgsql-bugs@lists.postgresql.org; Wed, 22 Feb 2023 14:53:48 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pUqV7-00041y-IC for pgsql-bugs@lists.postgresql.org; Wed, 22 Feb 2023 14:53:47 +0000 Received: by mail-il1-x12a.google.com with SMTP id i4so1935037ils.1 for ; Wed, 22 Feb 2023 06:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=TkyWfW/O14GpTgfp617QZG1ehK7jKBwNdNgs53Ug88k=; b=hp5Siib0+KeyDZutMatm40qnneUNIxzIjEA+Mnn9PlGR6HpEkwDiKl/83REARaNpBr 2jCYKWmcpGANNd+0u02IUQoiTHwJCfqrNTIaKjbNLkeh50VdBtBBR3h6D15fvgrbPVZh U+RKgqyKwidvzCJKQEU1pG0jjjmXsgtKZOGsTSvDEj5cgJEdGsDAJpBVSA/MqMF6zoxF JhsZl7WoiHhZvfJVR/V+Ods7idjSPqJDnjMDL3NmhvlSTEYVwYkqkxuuLoclrF5IamEH 1z3jt9Kx44Hu28UYEChKPdott2JKOfF/1GKYoUcFAzJL73RF3cNu8NJlOmyBt+wG39GL PuOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TkyWfW/O14GpTgfp617QZG1ehK7jKBwNdNgs53Ug88k=; b=p7gZ8tCZkdyUXLNnTYIRrb8LG8fPNQXJyIv0cQzjLYljX9p3VJOyPwklUGKbRSBf7h /ZS19velmcl5wTx2/gCORjey1l0QaI4QbXHqTHK8SMyc0COcbetq+sQMnTVJU5iyQoiv PSekIOGPz/EWKnZgg8CsdOeOsi8JT4+zJpYQDDNnVxIGYlp1tpyWgsVcPBVpQVHOudY/ gG729Okxv1lLNfkwARFWJLS3TpMGvMdeYgPJ33Fl/b+JlL5Mp55QCwomFzMwo9w0Ax9Y A5bUR1ljzDYdww/0A0qbgXKFdsHX/OB/H4ycoGk+2SzeWtykhkYdO+Ta82tHNkUvdRAf 6Geg== X-Gm-Message-State: AO0yUKWaseiyHqrQWKBpXXmEsh3DwkkfV2KYG2DVa0p6M3WKzagbX3lw jXr440m09ixlef8tPxlUHIDpUQ== X-Google-Smtp-Source: AK7set8XkxYBV5ojpJthkIpNU4UUO07ZwD2oHGnwdkXxKJ7tmo9Sk/DUGvLkZ5Zd9yc9MxTT7PjWMw== X-Received: by 2002:a05:6e02:1c22:b0:315:3421:ef2a with SMTP id m2-20020a056e021c2200b003153421ef2amr8011237ilh.25.1677077623370; Wed, 22 Feb 2023 06:53:43 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z2-20020a92d6c2000000b00304ad1e7d21sm2631853ilp.28.2023.02.22.06.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 06:53:42 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id A0A2D800354; Wed, 22 Feb 2023 08:53:41 -0600 (CST) Date: Wed, 22 Feb 2023 08:53:41 -0600 From: Justin Pryzby To: Heikki Linnakangas Cc: Duncan Sands , pgsql-bugs@lists.postgresql.org, Andres Freund Subject: Re: Unlimited memory consumption with long-lived connection Message-ID: <20230222145341.GT1653@telsasoft.com> References: <7484b4bd-a808-ed9e-892c-933f7f24120f@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7484b4bd-a808-ed9e-892c-933f7f24120f@iki.fi> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 21, 2023 at 04:32:02PM +0200, Heikki Linnakangas wrote: > On 21/02/2023 14:57, Duncan Sands wrote: > > If I execute the attached python script against a postgresql 15.2 (Ubuntu > > 15.2-1.pgdg22.10+1) server, with the default configuration (eg shared_buffers = > > 128M), then the server memory usage goes up and up, apparently endlessly. After > > about 10 minutes (on my laptop) pg_top shows RES memory usage for the back-end > > handling the connection as greater than 1 gigabyte, which seems far too high > > given the server configuration. The script just performs the same SELECT > > endlessly in a loop. The memory is released when the script is killed. > > > > Platform: Ubuntu 22.10; Linux version 5.19.0-31-generic; x86-64. > > > > PS: The testcase was reduced from a script that kept a connection open for a > > long time in order to LISTEN, and would execute a query using the same > > connection every time there was a notification on the channel. It consumed ever > > more memory to the point of crashing the postgresql server. Changing the script > > to perform the query using a new short-lived connection was an effective workaround. It sounds like the same as the issue here: https://wiki.postgresql.org/wiki/PostgreSQL_13_Open_Items There are patches proposed here, which fixed the issue for me. But I've always been suspicious that there may be a 2nd, undiagnosed issue lurking behind this one... https://www.postgresql.org/message-id/20210417021602.7dilihkdc7oblrf7%40alap3.anarazel.de