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 1mDTZC-0006EF-B8 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Aug 2021 15:21:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mDTZB-0007nY-46 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Aug 2021 15:21:21 +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 1mDTZA-0007lM-SS for pgsql-hackers@lists.postgresql.org; Tue, 10 Aug 2021 15:21:20 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDTZ7-0004CQ-V7 for pgsql-hackers@postgresql.org; Tue, 10 Aug 2021 15:21:20 +0000 Received: from hnk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id E2A866121E; Wed, 11 Aug 2021 00:21:11 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at oss.nttdata.com Subject: Re: RFC: Logging plan of the running query To: torikoshia , Pavel Stehule Cc: Bharath Rupireddy , Dilip Kumar , Pgsql Hackers References: <0842b5da697a03869fb50be93817e4e1@oss.nttdata.com> <1c1590d3962cea6e06621da76677b5f3@oss.nttdata.com> <64f716c44629e303b66e6c24502147cc@oss.nttdata.com> <8b53b32f-26cc-0531-4ac0-27310e0bef4b@oss.nttdata.com> <7958d03fffe3bafcfe8a505145c63928@oss.nttdata.com> From: Fujii Masao Message-ID: <9c4d9da6-48a5-fa18-4bff-f8eb0d4c9787@oss.nttdata.com> Date: Wed, 11 Aug 2021 00:21:11 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/08/10 21:22, torikoshia wrote: > I have updated the patch in this way. Thanks for updating the patch! > In this patch, getting the plan to the DO statement is as follows. Looks good to me. > Any thoughts? + ereport(LOG_SERVER_ONLY, + (errmsg("plan of the query running on backend with PID %d is:\n%s", + MyProcPid, es->str->data), + errhidestmt(true))); Shouldn't we hide context information by calling errhidecontext(true)? While "make installcheck" regression test was running, I repeated executing pg_log_current_query_plan() and got the failure of join_hash test with the following diff. This means that pg_log_current_query_plan() could cause the query that should be completed successfully to fail with the error. Isn't this a bug? I *guess* that the cause of this issue is that ExplainNode() can call InstrEndLoop() more than once unexpectedly. ------------------------------------------------------------------------------ $$ select count(*) from simple r join simple s using (id); $$); - initially_multibatch | increased_batches -----------------------+------------------- - f | f -(1 row) - +ERROR: InstrEndLoop called on running node +CONTEXT: PL/pgSQL function hash_join_batches(text) line 6 at FOR over EXECUTE statement rollback to settings; -- parallel with parallel-oblivious hash join savepoint settings; @@ -687,11 +684,9 @@ left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; $$); - multibatch ------------- - t -(1 row) - +ERROR: InstrEndLoop called on running node +CONTEXT: parallel worker +PL/pgSQL function hash_join_batches(text) line 6 at FOR over EXECUTE statement rollback to settings; -- single-batch with rescan, parallel-aware savepoint settings; ------------------------------------------------------------------------------ Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION