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 1w7s6n-005mPN-1E for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 09:43:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7s6l-00GQmN-2u for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 09:43:32 +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 1w7s6l-00GQm5-1k for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 09:43:32 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7s6i-00000002KXt-2J21 for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 09:43:31 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-486fd3a577eso60624095e9.1 for ; Wed, 01 Apr 2026 02:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1775036607; x=1775641407; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DbVLtAl8p7wk8TGiCd/GCrPT087OjSIicykJmaR/dVU=; b=KS5aWiHdQJaJtMbrKendM4ywtOKo0aWAu/RvH0YsdYbTWws3MqW3bIOLNogYvf3G3a KSKRx108lxdF0KslQE5ML3tRTpuxYAFaH8zvVzvlKwCK7qZAYwyideBA5BBBcPgLl8+F tS1A0dHSva5Krv9wM1dqDXesJL161QzryKbAyniAIBGrsuKEBTS01If8kE5Vn7IZd60f F7ukzGfMwPx9V7NZlR1ghnFyDgXCArc+esGwblpO3J5H4lrmpglNANsVRPPtqsXYHWmU u/kGM1mNJawP0sLeU8SLwi5ZW4i46LnH/KKrjA9YYtZ79zwiP/R5KY9Cba1aGp5bH+sh 0lVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775036607; x=1775641407; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DbVLtAl8p7wk8TGiCd/GCrPT087OjSIicykJmaR/dVU=; b=HVmdLVIl+43QDi2OJIfV0GbHlaYmC6alfoQjdSHfLM9zoUtygRSf1wsboFOWjkkMT1 H4BRjh+e+KLRVBSdaBGBBOotznsBH06ZMCIP9sJGMnt71Zy8BOWLw8PYo2vkCKQAWXn6 hhsC0t5cbw2grFVV6rHdgYthFvxJqF6hm7qkCyqOmcBZ8tnjHs7huPRPHmfEkYVj8PmY BLPoii2coRLGmeZ7A50NtjG3y+ZKFA9ojAYzmhx3c1No5L8VBBB9dXBtZ541wQMVUw79 DrP/CoeObNZRx4vR5mhPbIC9APE5z14nhOYQtUT9L0b7+C4GgaUqe1Oul4BcsRA7oov0 CxdA== X-Forwarded-Encrypted: i=1; AJvYcCXqq3ks2XR/R1E95gkU+wTpHF04OgbKvjSHejjT3J1LhOgDieEEunVY0aFr8LCID4eB6mmpRCmE1JruDhTV@lists.postgresql.org X-Gm-Message-State: AOJu0YyzANFNeyysdPh41J4qTWmAcpZt9hzW++91W+YAbbjB0ztW/4HI NrVuJjbamD66xZElr2hWYzbJVk8cvUOayHNDBSn2bJ34GSW+pIyZUh3VNEk62PKq+fM= X-Gm-Gg: ATEYQzxhQBYhwupONtoHo5lA3iTnikPB03DE1MmxzSMKLUieYNhQx6xwaZnknAj417v 7LcDe/js8+rGVY5Av2AILevhvBbfSrMo/V7aVkG32vsqcgeC8GzxcyTiyrfIqMmTa86ga9gTqEq 5vtzVe/76dcY58Hp59kiOYhnfa6IYXZnGgtdyEj4MO7+bJnaHc11z+2VreMM8Qm6ZolsVgvzuMn linjcOQff7+oSjpd6gdjSgi4NfEgj7JEdgGnX6aWoFKIw4VMXGVHJgplJNhc7N8sWhPxkOCk2eI zYLFx8ZCW5XxWceaqMm59jh3ZfT15btbYXsDqKWylPZ5sRwITprxcQXFPn6w5AbJghuC4Zt3KBz 8jtvsFH2iV5/jQ4XISeqchC2sPvdxuw/dvK6/px7mo3fza28iDL+UlBrgU0haujVtGLE1eJnHNg v0xVK56cSFl6DD/0ZOxoXAU86FtMJ2I+3eLR+h X-Received: by 2002:a05:600c:c056:b0:485:3a86:6392 with SMTP id 5b1f17b1804b1-488835b75c4mr31726715e9.20.1775036607440; Wed, 01 Apr 2026 02:43:27 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887c883b96sm37067715e9.17.2026.04.01.02.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 02:43:27 -0700 (PDT) From: Antonin Houska To: Amit Kapila cc: Alvaro Herrera , Mihail Nikalayeu , Srinath Reddy Sadipiralla , Matthias van de Meent , Pg Hackers , Robert Treat Subject: Re: Adding REPACK [concurrently] In-reply-to: References: <90700.1774627975@localhost> <202603271635.owyhm7btgoic@alvherre.pgsql> <228982.1774967782@localhost> Comments: In-reply-to Amit Kapila message dated "Wed, 01 Apr 2026 14:12:22 +0530." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 01 Apr 2026 11:43:26 +0200 Message-ID: <49194.1775036606@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Amit Kapila wrote: > On Tue, Mar 31, 2026 at 8:06=E2=80=AFPM Antonin Houska w= rote: > > > > Amit Kapila wrote: > > > 2. > > > * > > > + /* > > > + * TODO Consider a GUC to reserve certain amount of replication slot= s for > > > + * REPACK (CONCURRENTLY) and using it here. > > > + */ > > > +#define MAX_REPACK_XIDS 16 > > > + > > > > > > This sounds a bit scary as reserving replication slots for REPACK > > > (CONCURRENTLY) may not be what users expect. But it is not clear why > > > replication slots need to be reserved for this. > > > > The point is that REPACK should not block replication [1]. Thus reservi= ng > > slots for non-REPACK users is probably more precise statement. > > >=20 > oh, so shouldn't be a separate patch than this and an important for > this functionality to get committed? I don't see why we need to make > such a GUC or knob as part of this patch if we need the same. REPACK is a new user of replication slots. Without that, there is no other = way to "steal" the slots from the replication users. > > > IIUC, two reasons why logical decoding can ignore REPACK > > > (CONCURRENTLY) are (a) does not perform any catalog changes relevant > > > to logical decoding, (b) neither walsenders nor backends performing > > > logical decoding needs to care sending the WAL generated by REPACK > > > (CONCURRENTLY). Is that understanding correct? If so, we may want to > > > clarify why we want to ignore this command's WAL while sending changes > > > downstream in the commit message or give some reference of the patch > > > where the same is mentioned. This can help reviewing this patch > > > independently. > > > > Correct, but in fact this diff only affects the setup of the logical de= coding > > rather than the decoding itself. On the other hand, if REPACK (CONCURRE= NTLY) > > starts when the decoding backend's snapshot builder is already in the > > SNAPBUILD_FULL_SNAPSHOT state, reorderbuffer.c processes the transaction > > normally, and another part of the series (v46-0002) ensures that the ta= ble > > rewriting is not decoded: REPACK simply tells heap_insert(), heap_updat= e(), > > heap_delete() not to put the extra (replication specific) information i= nto the > > corresponding WAL records. I suppose this is what you mean in (b). > > > > Regarding (a), yes, the absence of catalog changes in the REPACK's tran= saction > > is the reason that even the logical decoding setup does not have to wai= t for > > the transaction to finish. > > >=20 > Hmm, but we don't do any catalog changes for transactions that have > DML say only INSERT but we don't have separate logic like REPACK in > snapbuild machinery. Same is probably true for dml operations on an > unlogged table which doesn't have WAL to send nor any catalog > operations involved but we don't have any special path for that in > snapbuild code path. So, why do we need special handling for this > operation? If an "ordinary" transaction, which had started before the snapshot builder reached the SNAPBUILD_FULL_SNAPSHOT state, runs DML, the snapshot builder d= oes not know if the same transaction changed something in the catalog earlier. = So it needs to wait for this transaction to finish before it advances to SNAPBUILD_CONSISTENT. For REPACK, we know that it cannot happen because it cannot run in transaction block for other reasons. So the snapshot builder does not have to wait. Nevertheless, I'm not sure it's a good idea for snapbuild.c to handle speci= al cases like REPACK. Instead, I'm thinking if snapbuild.c can safely ignore X= IDs of backends connected to databases other than the one we're decoding. Thus = the restriction would be one backend running REPACK per database rather than cluster. --=20 Antonin Houska Web: https://www.cybertec-postgresql.com