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 1qD6Yf-0005K2-Iv for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Jun 2023 16:56:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qD6Yd-0004Xg-1l for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Jun 2023 16:56:19 +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 1qD6Yc-0004XV-PL for pgsql-bugs@lists.postgresql.org; Sat, 24 Jun 2023 16:56:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qD6YV-000FJb-AF for pgsql-bugs@lists.postgresql.org; Sat, 24 Jun 2023 16:56:17 +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 35OGu6Tl229226; Sat, 24 Jun 2023 12:56:06 -0400 From: Tom Lane To: Zu-Ming Jiang cc: pgsql-bugs@lists.postgresql.org Subject: Re: Server closed the connection unexpectedly (memory leak) In-reply-to: <08f7224c-2de9-0996-549a-c9e9d806fdef@inf.ethz.ch> References: <08f7224c-2de9-0996-549a-c9e9d806fdef@inf.ethz.ch> Comments: In-reply-to Zu-Ming Jiang message dated "Fri, 23 Jun 2023 18:06:34 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <229224.1687625766.1@sss.pgh.pa.us> Date: Sat, 24 Jun 2023 12:56:06 -0400 Message-ID: <229225.1687625766@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Zu-Ming Jiang writes: > My fuzzer finds a bug in Postgres, which makes the connection closed > unexpectedly. TBH, I think there's not much to be learned here, beyond "a ridiculously complicated query takes a ridiculous amount of memory to plan". The reason for the backend crash is presumably that the OOM killer decided to zap it. If you run the postmaster under a "ulimit -v" setting that's small enough to act before the OOM killer does, then you get an unexciting "out of memory" error. I did find that if you mark cte_3 as MATERIALIZED, the resource consumption is a lot less --- but you get a plan that requires 41191 lines to EXPLAIN, so it's still way outside any bounds of reasonability. Perhaps there's room there to argue that we shouldn't flatten CTE subqueries that are "too big" ... but it's hard to decide how to measure "too big". regards, tom lane