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.96) (envelope-from ) id 1vV9Vz-00EBDg-39 for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 14:25:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vV9Vy-000gwd-0Y for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Dec 2025 14:25:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vV9Vx-000gwV-2Z for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 14:25:30 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vV9Vv-000sDj-1i for pgsql-hackers@lists.postgresql.org; Mon, 15 Dec 2025 14:25:30 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6C0941400266; Mon, 15 Dec 2025 09:25:25 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 15 Dec 2025 09:25:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1765808725; x=1765895125; bh=M DjB2v98Da9w//NVKh3jl9dCNe6hl1IDE2z9zwK6/Kg=; b=nj4YjpqRoESYTv1RT gH7GcQSptOQeHLhowfq7qtugqNbHgJFywyFcba8tE3rRPDoRrD5UmdoKaf9dgBY2 snWbvu3e1WTkg2/AsrprcnmyPLmBsSYRBqdQBs0e5XucQOpxyQZH3qME8THNQkuZ jI6Xd8bh//ojn9dzirocil1hMpieJxit57yCMTSC7ugdpTpVHi0W/Q8a3wKVd7lH WZrMhtIsDGyDS897Xdym3CC+JNjmRVb1y/f252w5ejUSFaQQMy4rdY8xUG5yMDUk OovAyqnGHGEirWX1G0W+YWben4wh11lBGFOQaZlvrSW2AnmOnsWfE7jh/sGdG9MT 5AbXQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefjedthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghrohcu jfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqeenuc ggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeffgfdu fffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghr rhgvsegrlhhvhhdrnhhoqdhiphdrohhrghdpnhgspghrtghpthhtohepgedpmhhouggvpe hsmhhtphhouhhtpdhrtghpthhtoheprghhsegthigsvghrthgvtgdrrghtpdhrtghpthht ohepmhhihhgrihhlnhhikhgrlhgrhigvuhesghhmrghilhdrtghomhdprhgtphhtthhope hpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdp rhgtphhtthhopehrohgsseigiihilhhlrgdrnhgvth X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Dec 2025 09:25:24 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1765808722; bh=SeqB6OsuanC20mph/DCVY1pjOYQ531rqnxVys0PdpvM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Gdx6Wb7sxXUMfXizjvSofMobDQPZp5bBT/yh6VMDfIl3PyUzt41rz2xJ+m6GzIQ9I waFGaGlC255j+Z4J0GiyU8gHNEScAJZGbVbMi4J4v9ghQTl/WoV1bq8bwDzl48/x/F RUAgCVpzAL7lBWJ6T9CamLqKcpctFMO5tXfOm9rBZeHqcLvLJYA0P0KL4aEGGfMKI4 AWwosfnVmxG3s2ntp4fdGwXZAhN7leKwzOjdy5q97e7b/gFuvV4Vqs+7XhSrMZ+VoO Nn7AibkApVySW91hWopjZoE+XQzezbt3Ad7cgC2wSDrFk17H0/k5bh+zL7Oh3Xe1NX 9nkoxY/XVL/ZQ== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 55B7E78; Mon, 15 Dec 2025 15:25:22 +0100 (CET) Date: Mon, 15 Dec 2025 15:25:22 +0100 From: Alvaro Herrera To: Antonin Houska Cc: Mihail Nikalayeu , Pg Hackers , Robert Treat Subject: Re: Adding REPACK [concurrently] Message-ID: <202512151349.vlq3mpfniyk3@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <210036.1765651719@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Dec-13, Antonin Houska wrote: > From 6279394135f2b693b6fffd174822509e0a067cbf Mon Sep 17 00:00:00 2001 > From: Antonin Houska > Date: Sat, 13 Dec 2025 19:27:18 +0100 > Subject: [PATCH 4/6] Add CONCURRENTLY option to REPACK command. > diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c > index cc03f0706e9..a956892f42f 100644 > --- a/src/backend/replication/logical/decode.c > +++ b/src/backend/replication/logical/decode.c > @@ -472,6 +473,88 @@ heap_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) > + /* > + * Second, skip records which do not contain sufficient information for > + * the decoding. > + * > + * The problem we solve here is that REPACK CONCURRENTLY generates WAL > + * when doing changes in the new table. Those changes should not be useful > + * for any other user (such as logical replication subscription) because > + * the new table will eventually be dropped (after REPACK CONCURRENTLY has > + * assigned its file to the "old table"). > + */ > + switch (info) > + { > + case XLOG_HEAP_INSERT: > + { > + xl_heap_insert *rec; > + > + rec = (xl_heap_insert *) XLogRecGetData(buf->record); > + > + /* > + * This does happen when 1) raw_heap_insert marks the TOAST > + * record as HEAP_INSERT_NO_LOGICAL, 2) REPACK CONCURRENTLY > + * replays inserts performed by other backends. > + */ > + if ((rec->flags & XLH_INSERT_CONTAINS_NEW_TUPLE) == 0) > + return; > + > + break; > + } > + > + case XLOG_HEAP_HOT_UPDATE: > + case XLOG_HEAP_UPDATE: > + { > + xl_heap_update *rec; > + > + rec = (xl_heap_update *) XLogRecGetData(buf->record); > + if ((rec->flags & > + (XLH_UPDATE_CONTAINS_NEW_TUPLE | > + XLH_UPDATE_CONTAINS_OLD_TUPLE | > + XLH_UPDATE_CONTAINS_OLD_KEY)) == 0) > + return; > + > + break; > + } > + > + case XLOG_HEAP_DELETE: > + { > + xl_heap_delete *rec; > + > + rec = (xl_heap_delete *) XLogRecGetData(buf->record); > + if (rec->flags & XLH_DELETE_NO_LOGICAL) > + return; > + break; > + } > + } I'm confused as to the purpose of this addition. I took this whole block out, and no tests seem to fail. Moreover, some of the cases that are being skipped because of this, would already be skipped by code in DecodeInsert / DecodeUpdate anyway. The case for XLOG_HEAP_DELETE seems to have no effect (that is, the "return" there never hits for any tests as far as I can tell.) The reason I ask is that the line immediately below does this: > ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr); which means the Xid is tracked for snapshot building purposes. Which is probably important, because of what the comment right below it says: /* * If we don't have snapshot or we are just fast-forwarding, there is no * point in decoding data changes. However, it's crucial to build the base * snapshot during fast-forward mode (as is done in * SnapBuildProcessChange()) because we require the snapshot's xmin when * determining the candidate catalog_xmin for the replication slot. See * SnapBuildProcessRunningXacts(). */ So what happens here is that we would skip processing the Xid of a xlog record during snapshot-building, on the grounds that it doesn't contain logical changes. I'm not sure this is okay. If we do indeed need this, then perhaps it should be done after ReorderBufferProcessXid(). Or did you intend to make this conditional on the backend running REPACK? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/