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 1w7sia-005nPQ-18 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 10:22:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7siY-00GZkm-0g for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 10:22:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7siX-00GZke-2a for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 10:22:34 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7siV-000000027aP-16Fs for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 10:22:33 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-38a43f1f978so58231851fa.3 for ; Wed, 01 Apr 2026 03:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775038948; cv=none; d=google.com; s=arc-20240605; b=fsT/STRgoN4O83huBNH1UxmxrqPe2S0AbdYbUbDpqxIBXHoWnzv+8XFq/+62hc8+kb lYvuubtEeyURox3N2GSg2pg03kGP9gDBfelpEOohaZNB9OgHmPYjhJZJ8LAf7Cnlquuk OM0Nh2pyYl+ngU4URBJjeZcxz+vQa9KiMH46oqj36SxmkGRZ8U8FYJjrb8TMNyBYq01g g8CtHoafmL8euipl4kO+9d2Z7z1/iJAPyDfmEaO3wLFATq7kGWLQUFkNnu7nHuGT8tja tRKCU7Pgn1BN10KFsAouinbPz0Tv0OfFDP9fhlzTa0KXx5cMYDcZ1JCoY/uhR8XsDpYT A3RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ihpD4csT/7iCmnOfcwiTN3qnwCXpTlfZmpuI1vap6wM=; fh=LoDLhE+VVIvZRnWD5ho2MjJB1kTB6Egoyi7mOu3dkRg=; b=kKjk6GzFVOMJFOI8URJKP9cFii14S1LFJvAKUDxZ6JpknSZ11H4cbKVonw0ir35Nud YMn1hixKNyJ/vpHLGFMKZTPsfws83hxQeLJVROUs2cPxGQU9ZrT3ut+vdjSWshQBUbZH 3eAyuBo0tuvUJFZ8KBY2gq7pUleVLMi+G/0lgiNpmJfAgKZ/nBJFrH3tqeq/1kadwaww +rtURYDu12wE8YO5M4dsFaaOhgaqmXpoFonLaaj15CjEv59FVN9X3PzgognDsoMGbPhw 4rD75ErtIRTqp5dAZO5PC8AGRPYYr3A/GQXvAMQFk67W+2Ebm2Y+4mQ47UnwVvO/d1Ey 547w==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775038948; x=1775643748; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ihpD4csT/7iCmnOfcwiTN3qnwCXpTlfZmpuI1vap6wM=; b=GApVcLZr9sxRBC+eS55XTQ004gXopFKu56TwnlgmcnXe0yXNfe7uMw1jyJdBcPGJBE AXSr7ZUw8fqN2bLcWQ35rVXIS3rftAAkWmkcivvReT5KMVA8fo3V6PbGLy2udJHCRIVr XfjFsGI6rsX7uaKdvJOSh5RcTOTQulT/6nRcUUzMpi+F5ivZdu74Y9rlTwvSzpGrjw/S +6xVvaOGHm9r5xsiRXXuG3rvK5h/nw23fuje8er4MXk7VrNPf1fl0WlpVAnaDiPNqfB4 p8g38LUX5rGIl3Y1y1n7E6dE0VibKGniwV1Sel+wAKRL8d69r5OMDhpYjlXn9svlI3OR 89/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775038948; x=1775643748; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ihpD4csT/7iCmnOfcwiTN3qnwCXpTlfZmpuI1vap6wM=; b=LlukAqIB/KROpfW4EpWqnq2UptHb/xTWJd7T5GXw6YGTAeFX9JQooRQ4aja/fAsq0P 3BuUp8aVD5jsMrAXpTm1AqLLVQbv52NzFRd10iM6TpoQnFHQZH0mCfoz2QPu8H89R6ZH JmQwpT9GcSJiWTS/4/s7JHL6mSCdJ4wYXIBea3p2QX0Nyhpr2XYKMnTVq1KrV6jUoeqd 6ubkWF0NKcLe9f5RGo+cvasyXzmxRB72EC7gWrrYYUALTVaS2E6yRwpRLi9rBzZwPq3F B1fSpt1aDdcbDvHUIqCYNT79bzx585Gd9yQ+dsAcbNKhXdIBIjbTXSHZUylkzrKUp405 4I6A== X-Forwarded-Encrypted: i=1; AJvYcCUBRzlTMCobp1aNteOAuFQJeGBABpHG0wY4moZTqBZ1SO8kKrCPIm0QYoTbrDlKoAYKVtltQwIIA/TCvFgu@lists.postgresql.org X-Gm-Message-State: AOJu0YxPTz6UDzh1ophQTfLZ+AjPumjipSOn1sYZqPbNAPRj17oiVSRf GC97hI9D7Pkp+K5/CDDzESZSNjwQpqlcuRF0gzbD87mb6DjCRWzF4Ow4DZXH4tXRVYVs/+bq60C ZC3LRaSg7I/L1LODvKt04NeGBZAwwViU= X-Gm-Gg: ATEYQzwg6EF/Zvf3YDvID9lVqS98tBY/bG4rZgIBtUqNbEnj+axOcaZlZtl22up7J9n vpEOuhtxkSD1/pbqT02uh+XLo0uU8c+0uNfW5O84pfZo7UXrFHwklEcWUu1rjLPDH4VuXafDFs2 dKGb3s5CzeqDBBU5HrngrfWd7QQqp41PfYAosuvfwKbZ8SteIRlxgeux76cagmyE37zi3BR2kn5 BSf2EkXAPeCfXE2bbiCngi+225lsgnGjRFgj7k+XwDnVfj/qc22krmzVX5abzPir/mECsmoOLcb 18egY2qF0GV2O39NexweKs98ybxHFeC5nGze X-Received: by 2002:a05:651c:2551:20b0:38b:fbb9:42c4 with SMTP id 38308e7fff4ca-38cc2f666b2mr8703881fa.4.1775038947917; Wed, 01 Apr 2026 03:22:27 -0700 (PDT) MIME-Version: 1.0 References: <90700.1774627975@localhost> <202603271635.owyhm7btgoic@alvherre.pgsql> <228982.1774967782@localhost> <49194.1775036606@localhost> In-Reply-To: <49194.1775036606@localhost> From: Amit Kapila Date: Wed, 1 Apr 2026 15:52:15 +0530 X-Gm-Features: AQROBzCyLrhfTzjDrC2Z6Vc1FQu-SXp7IMeJcBPfmelu2E5_zDXXNn1eB5B0kwE Message-ID: Subject: Re: Adding REPACK [concurrently] To: Antonin Houska Cc: Alvaro Herrera , Mihail Nikalayeu , Srinath Reddy Sadipiralla , Matthias van de Meent , Pg Hackers , Robert Treat Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 1, 2026 at 3:13=E2=80=AFPM Antonin Houska wrot= e: > > Amit Kapila wrote: > > > On Tue, Mar 31, 2026 at 8:06=E2=80=AFPM Antonin Houska = wrote: > > > > > > Amit Kapila wrote: > > > > 2. > > > > * > > > > + /* > > > > + * TODO Consider a GUC to reserve certain amount of replication sl= ots 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 wh= y > > > > replication slots need to be reserved for this. > > > > > > The point is that REPACK should not block replication [1]. Thus reser= ving > > > slots for non-REPACK users is probably more precise statement. > > > > > > > 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 othe= r 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 relevan= t > > > > 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 t= o > > > > clarify why we want to ignore this command's WAL while sending chan= ges > > > > downstream in the commit message or give some reference of the patc= h > > > > 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 = decoding > > > rather than the decoding itself. On the other hand, if REPACK (CONCUR= RENTLY) > > > starts when the decoding backend's snapshot builder is already in the > > > SNAPBUILD_FULL_SNAPSHOT state, reorderbuffer.c processes the transact= ion > > > normally, and another part of the series (v46-0002) ensures that the = table > > > rewriting is not decoded: REPACK simply tells heap_insert(), heap_upd= ate(), > > > heap_delete() not to put the extra (replication specific) information= into 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 tr= ansaction > > > is the reason that even the logical decoding setup does not have to w= ait for > > > the transaction to finish. > > > > > > > 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 build= er > reached the SNAPBUILD_FULL_SNAPSHOT state, runs DML, the snapshot builder= does > 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 i= t > cannot run in transaction block for other reasons. So the snapshot builde= r > does not have to wait. > > Nevertheless, I'm not sure it's a good idea for snapbuild.c to handle spe= cial > cases like REPACK. Instead, I'm thinking if snapbuild.c can safely ignore= XIDs > of backends connected to databases other than the one we're decoding. > What if such transactions have made changes in the global catalog? Even if that won't matter, I feel such a change would be quite fundamental to snapbuild machinery and changing at this point would be risky. BTW, is the reason to skip REPACK while building a snapshot is that it can take a long time to finish? --=20 With Regards, Amit Kapila.