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 1lqlce-0004Ab-UO for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jun 2021 23:59:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqlcc-0003xt-6G for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Jun 2021 23:59:02 +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 1lqlcb-0003xl-UH for pgsql-hackers@lists.postgresql.org; Tue, 08 Jun 2021 23:59:01 +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 1lqlcZ-0001Vx-P5 for pgsql-hackers@lists.postgresql.org; Tue, 08 Jun 2021 23:59:01 +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 158NwuxY1254158; Tue, 8 Jun 2021 19:58:57 -0400 From: Tom Lane To: Mark Dilger cc: PostgreSQL Hackers , Peter Eisentraut , Simon Riggs Subject: Re: logical replication of truncate command with trigger causes Assert In-reply-to: References: <1250962.1623192946@sss.pgh.pa.us> Comments: In-reply-to Mark Dilger message dated "Tue, 08 Jun 2021 16:23:47 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1254156.1623196736.1@sss.pgh.pa.us> Date: Tue, 08 Jun 2021 19:58:56 -0400 Message-ID: <1254157.1623196736@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mark Dilger writes: > On Jun 8, 2021, at 3:55 PM, Tom Lane wrote: >> I suppose that either apply_dispatch or LogicalRepApplyLoop needs to >> grow some more snapshot management logic, but I've not looked at that >> code much, so I don't have an opinion on just where to add it. > I was looking at those for other reasons prior to hitting this bug. After looking at it a bit, I see a couple of options: 1. Just wrap the call of ExecuteTruncateGuts with PushActiveSnapshot(GetTransactionSnapshot()) and PopActiveSnapshot(). 2. Decide that we ought to ensure that a snapshot exists throughout most of this code. It's not entirely obvious to me that there is no code path reachable from, say, apply_handle_truncate's collection of relation OIDs that needs a snapshot. If we went for that, I'd think the right solution is to do PushActiveSnapshot right after each ensure_transaction call, and then PopActiveSnapshot on the way out of the respective subroutine. We could then drop the snapshot management calls that are currently associated with the executor state. > My purpose was to figure out how to get the code to respect > privileges. Perhaps the solution to these two issues is related. > I don't know yet. Doesn't seem tremendously related. But yeah, there is Stuff That Is Missing in these code paths. regards, tom lane