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 1opjGe-0006ku-MU for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Nov 2022 04:52:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1opjGd-0002SB-Cj for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Nov 2022 04:52:51 +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 1opjGd-0002S1-4M for pgsql-bugs@lists.postgresql.org; Tue, 01 Nov 2022 04:52:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opjGb-0000AP-4l for pgsql-bugs@lists.postgresql.org; Tue, 01 Nov 2022 04:52:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2A14qGMs1084049; Tue, 1 Nov 2022 00:52:16 -0400 From: Tom Lane To: David Rowley cc: Andres Freund , lauri.laanmets@eesti.ee, pgsql-bugs@lists.postgresql.org Subject: Re: Memory leak on subquery as scalar operand In-reply-to: References: <1046179.1667263449@sss.pgh.pa.us> <1073512.1667275802@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 01 Nov 2022 17:26:16 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1084047.1667278336.1@sss.pgh.pa.us> Date: Tue, 01 Nov 2022 00:52:16 -0400 Message-ID: <1084048.1667278336@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > The single subquery version also crashes for me, so perhaps it's just > the amount of memory that's being used and when the OOM killer is > triggering. > It crashes even when I set jit_inline_above_cost and > jit_optimize_above_cost above the query's cost. Hmm, maybe we're not seeing the same thing? For me, the behavior seems similar to what the OP reported: there's a per-query leakage but it's less than 100kB per query. It'd take more than a handful of repetitions to get to an OOM failure. This is with LLVM 13.0.1 on RHEL 8.6. Also, as far as I can see there is no leak with the single-subquery version. The process's reported VIRT consumption bounces around a fair amount, but it doesn't go above 300MB, even after ~10min in a tight plpgsql DO loop. VIRT bounces around a lot with the two-subquery version too, actually, but there does seem to be a general uptrend there. I did not have the patience to wait for actual OOM; it looked like it'd take a good long while, tens of minutes at least. If the behavior varies across LLVM versions, as is now seeming a bit likely, it might be their bug not ours. regards, tom lane