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 1ljDAG-0000f0-ER for pgsql-hackers@arkaria.postgresql.org; Wed, 19 May 2021 03:46:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ljDAF-0005Kw-9O for pgsql-hackers@arkaria.postgresql.org; Wed, 19 May 2021 03:46:31 +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 1ljDAF-0005Ko-1h for pgsql-hackers@lists.postgresql.org; Wed, 19 May 2021 03:46:31 +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 1ljDAB-0005ae-UM for pgsql-hackers@lists.postgresql.org; Wed, 19 May 2021 03:46:30 +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 14J3kPvn3392912; Tue, 18 May 2021 23:46:25 -0400 From: Tom Lane To: Michael Paquier cc: pgsql-hackers@lists.postgresql.org Subject: Re: Subscription tests fail under CLOBBER_CACHE_ALWAYS In-reply-to: References: <3382681.1621381328@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Wed, 19 May 2021 12:03:50 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3392910.1621395985.1@sss.pgh.pa.us> Date: Tue, 18 May 2021 23:46:25 -0400 Message-ID: <3392911.1621395985@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Tue, May 18, 2021 at 07:42:08PM -0400, Tom Lane wrote: >> This might go away if worker.c weren't so creatively different >> from the other code paths concerned with executor shutdown. > The tuple routing has made the whole worker logic messier by a larger > degree compared to when this stuff was only able to apply DMLs changes > on the partition leaves. I know that it is not that great to be more > creative here, but we need to make sure that AfterTriggerEndQuery() is > moved before ExecCleanupTupleRouting(). We could either keep the > ExecCleanupTupleRouting() calls as they are now, and call > AfterTriggerEndQuery() in more code paths. Or we could have one > PartitionTupleRouting and one ModifyTableState created beforehand > in create_estate_for_relation() if applying the change on a > partitioned table but that means manipulating more structures across > more layers of this code. Something like the attached fixes the > problem for me, but honestly it does not help in clarifying this code > more. I was wondering if we could move the ExecCleanupTupleRouting call into finish_estate. copyfrom.c, for example, does that during its shutdown function. Compare also the worker.c changes proposed in https://www.postgresql.org/message-id/3362608.1621367104%40sss.pgh.pa.us which are because I discovered it's unsafe to pop the snapshot before running AfterTriggerEndQuery. regards, tom lane