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 1ragxC-00B03x-5I for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Feb 2024 18:59:27 +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 1ragx8-00F0cw-Nz for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Feb 2024 18:59:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ragx6-00F0co-Sa for pgsql-hackers@lists.postgresql.org; Thu, 15 Feb 2024 18:59:22 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ragx3-006vLJ-64 for pgsql-hackers@lists.postgresql.org; Thu, 15 Feb 2024 18:59:19 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 4ADE83200A4C; Thu, 15 Feb 2024 13:59:14 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 15 Feb 2024 13:59:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1708023553; x=1708109953; bh=hbsmt8stWB 2OfLcU8349Bj+LUAhjPzvN8ARePUR9/G4=; b=A6kSodZN+eYYKPS2hk9cnm9awq rhQ+QCEkJuVc6it034uznuBPKLPniKdo4/O1kuX928j3ZuS7dVwxmjMCUl3HK7FQ 4/vYIZAK1fK1Dp+2CVu9ysaMDp8f6emULr1JdgDJ4qzHWU+143BzPB12qgiRGPXL DRKsrxZr51oYFG2xcDiRvaY5DJe6CTxDMBluafqNWvNXYncc+p7yspjtXSfnShqk dvs3Zek5dvdbyobcR5PZzXUfCQuBi6sSwm0RGGRps+Zu3nATfLcXKfUa/5noIRZW jSCfKUTkmQtVBO6OA1bkIY8zsMkKGwGNNFVIudKZf+fpdyqAY/JNWF1ntyqQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708023553; x=1708109953; bh=hbsmt8stWB2OfLcU8349Bj+LUAhj PzvN8ARePUR9/G4=; b=IKsPuQk8bf/hp6fmXMs5SWvAzqQLF1Fy2s4GgO8OjbYa S2w6svdxBzB1pUeKfkcZJ1y4J9yJd2qiRgt/OcAIDLvf/ej1/ezAelMTCHWbUY4F GcSDDEThvtFGAwyT+Way7nTUcLlRqdX8VCJM49k3G9k7pMsQ5q0FtWWcH/eSUSZx YKOWrQlSxxHHOedET9O6SgTACMm04aEN8n+B+UVZWyzsD31ctiOVSAVuu6hIPzI6 JSiybzbdqElWolneFc1EdfAdEbl4q+ekRMcAYm33YMccFela38vEsY3rgGvwFWtF xmINrg/i15IBfBWLhTv92MgkgKqDJQkHuJrTjofu9g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddtgdduvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepgeetveejudeuudeuhfeftdffheetgfevudeftdefvefgieefgfejuddv ffegfeeknecuffhomhgrihhnpehpohhsthhgrhdrvghsnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdr uggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 15 Feb 2024 13:59:12 -0500 (EST) Date: Thu, 15 Feb 2024 10:59:11 -0800 From: Andres Freund To: Robert Haas Cc: torikoshia , pgsql-hackers@lists.postgresql.org, =?utf-8?Q?=C3=89tienne?= BERSAC , jtc331@gmail.com, ashutosh.bapat.oss@gmail.com, rafaelthca@gmail.com, jian.universality@gmail.com Subject: Re: RFC: Logging plan of the running query Message-ID: <20240215185911.v4o6fo444md6a3w7@awork3.anarazel.de> References: <61b4add9a01f21011789b6ee04085751@oss.nttdata.com> <3d5fd6d955944b5e8e4b8d1917f14885@oss.nttdata.com> <67fac921c935d7b9db51609a7599520f@oss.nttdata.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2024-02-15 14:42:11 +0530, Robert Haas wrote: > I think the issue is very general. We have lots of subsystems that > both (a) use global variables and (b) contain CHECK_FOR_INTERRUPTS(). > If we process an interrupt while that code is in the middle of > manipulating its global variables and then again re-enter that code, > bad things might happen. We could try to rule that out by analyzing > all such subsystems and all places where CHECK_FOR_INTERRUPTS() may > appear, but that's very difficult. Suppose we took the alternative > approach recommended by Andrey Lepikhov in > http://postgr.es/m/b1b110ae-61f6-4fd9-9b94-f967db9b53d4@app.fastmail.com > and instead set a flag that gets handled in some suitable place in the > executor code, like ExecProcNode(). If we did that, then we would know > that we're not in the middle of a syscache lookup, a catcache lookup, > a heavyweight lock acquisition, an ereport, or any other low-level > subsystem call that might create problems for the EXPLAIN code. > > In that design, the hack shown above would go away, and we could be > much more certain that we don't need any other similar hacks for other > subsystems. The only downside is that we might experience a slightly > longer delay before a requested EXPLAIN plan actually shows up, but > that seems like a pretty small price to pay for being able to reason > about the behavior of the system. I am very wary of adding overhead to ExecProcNode() - I'm quite sure that adding code there would trigger visible overhead for query times. If we went with something like tht approach, I think we'd have to do something like redirecting node->ExecProcNode to a wrapper, presumably from within a CFI. That wrapper could then implement the explain support, without slowing down the normal execution path. > I don't *think* there are any cases where we run in the executor for a > particularly long time without a new call to ExecProcNode(). I guess it depends on what you call a long time. A large sort, for example, could spend a fair amount of time inside tuplesort, similarly, a gather node might need to wait for a worker for a while etc. > It's really hard for me to accept that the heavyweight lock problem > for which the patch contains a workaround is the only one that exists. > I can't see any reason why that should be true. I suspect you're right. Greetings, Andres Freund