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 1w7aCh-005T2s-2V for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 14:36:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7aCg-00AehC-1B for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 14:36:26 +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 1w7aCg-00Aeh2-09 for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 14:36:26 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7aCe-00000001yvT-2GCI for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 14:36:25 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-43cf5d14d6eso2382780f8f.0 for ; Tue, 31 Mar 2026 07:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1774967783; x=1775572583; 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=TEeH4o/0TCR63Sl3rJbSufEtEamRNzRXwYX6jeQJo4I=; b=eml7uFGUOo4UwUSWkqB6to2aHoijYPvr9+dJ0V7Iwb+ReZ8dY3qutcR8f8aUFnQims uRD/94jVtmEB40OfO5y8vvYJltaxsHwEMS5cv+hzLpZO4RJavNe4t+gOMPaHd+outsEB rDopvtAQjkv6wRkC/TQ3S5RtXnbyv7liIk3+Coum3vxPQjU+virNFqzfWA3yf1bKJTjk 7AeSuUj4BKOieIPB8+QMXGPVsDCvJHtVC9iUV9w73ewUfFOQ85EfFxWRD3zupS5ugH45 l9q/1dcL95vTT6rblAxWDNmzRZmb9hyQ65s0Fe8TknvGMtySHpaJkGZQbRDTXN/COEBb R7RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774967783; x=1775572583; 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=TEeH4o/0TCR63Sl3rJbSufEtEamRNzRXwYX6jeQJo4I=; b=ITEW/IgaiklWt/qSQuOwkQgpNMzjc8JJsw9snV9jGoMGCHlbjcFDlWwkZQvElQRa+M kT/HH7M2hLm3Eqas1WPym8pHjahA6yA/rfnMp54s5IiVlNWVfP4b8pCMe0Y4RopgOhMT y/LIRWsyeVdNurHZ1JIIdZvZ9RkphY1qgVpgj2P5awqhDywFdhNiLCaU1gnBukjqM+nK pZRIrfif5gi34qmn/axIdIX7884OxJHrdLndKg0PdsTUH5cULdePFSk1PjlqZRSZ8jnj ZubDq3E9CRWlQDRdNgG30b8Qm9Ik2e3FgTYnI8u+pvjeAAtNeHT2kjhS9T/C3l94ckUB qnUA== X-Forwarded-Encrypted: i=1; AJvYcCVmfYNlNSxbof5uRlx6iRmYtCIU8LxBI+cQ0X2M7iuNvBfMDw+Xz9gJ5iCn6oIdxxhOKnxHbFeBZ+xEDxGr@lists.postgresql.org X-Gm-Message-State: AOJu0YztJBTVdNnmxVg8MXqd5ghTHbBsxBm2vTwpS98m2eUo+HvszvwJ rErC9TN/0Xvil7l6dMLDs4T2hFl5Im1oMRlwsA7f2dn5nNsVtWJnlCpXsnposbVO1y8= X-Gm-Gg: ATEYQzyksH7kn9hpNgElMTxUv4qXXNWyHTAtxAX6FtFVzJ0ZsRI77fLoz49J2WsfgV9 Z+s6Qgj/Xb6kCK2ZgqiMplivDWoleHJjoAhEh+S7QYgmRut3ecxAUzztRjfEMzPtzxVnQ5bStX3 9fTpwGg5hhCl5QAdptheeEelAB9dSeZ0lZhqaUVPJITV9bKfNMtTj6VzI53YxLOc099FcpcoM6o mL5WmDmEPH3txzpAeLhblQqHU6/y8wjiC9PmGZWMWpM25xyOfVAIlXCaQaIVk54CzRtLCZjCnMI mWlScABoFMKi20BZFvR1YdkqpwopGsY40N3LT9lgQ89PXgBSIG3XtwmHxuT+8XMLVfZ3E6S7/rF j22U6s3rVTN2W/4QO9tBv7+D4Bd6PwUtNnbFBnbMgXGRTmAwESHne2/gr64CkU91QFv8F9rPCO2 7Q95STReMZEaet9xsH1Gbkl3zPIFgYRVln5stH X-Received: by 2002:a05:6000:60f:b0:43d:dd7:3657 with SMTP id ffacd0b85a97d-43d0dd73b66mr3931200f8f.46.1774967782909; Tue, 31 Mar 2026 07:36:22 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43cf247079esm27907714f8f.25.2026.03.31.07.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 07:36:22 -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> Comments: In-reply-to Amit Kapila message dated "Tue, 31 Mar 2026 16:17:18 +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: Tue, 31 Mar 2026 16:36:22 +0200 Message-ID: <228982.1774967782@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Amit Kapila wrote: > On Fri, Mar 27, 2026 at 10:31=E2=80=AFPM Alvaro Herrera wrote: > > > > Lastly, 0008 is "Teach snapshot builder to skip transactions running > > REPACK (CONCURRENTLY)" which I see as the least mature of the pack. I > > would really like to be able to squash it with 0003, but I'm not yet > > trusting it enough. > > >=20 > Few comments/questions by looking 0008 alone: Thanks. > 1. > + TransactionId *xids_repack =3D NULL; > + bool logical_decoding_enabled =3D IsLogicalDecodingEnabled(); >=20 > Assert(!RecoveryInProgress()); >=20 > ... > ... >=20 > /* > * Allocating space for maxProcs xids is usually overkill; numProcs would > * be sufficient. But it seems better to do the malloc while not holding > @@ -2663,11 +2672,14 @@ GetRunningTransactionData(void) > */ > if (CurrentRunningXacts->xids =3D=3D NULL) > { > + /* FIXME probably fails if logical decoding is enable on-the-fly */ > + int nrepack =3D logical_decoding_enabled ? MAX_REPACK_XIDS : 0; >=20 > This FIXME is important to fix for this patch, otherwise, we can't > rely on transactions remembered as repack_concurrently. Indeed. > 2. > * > + /* > + * TODO Consider a GUC to reserve certain amount of replication slots for > + * REPACK (CONCURRENTLY) and using it here. > + */ > +#define MAX_REPACK_XIDS 16 > + >=20 > 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 reserving slots for non-REPACK users is probably more precise statement. > 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 decodi= ng rather than the decoding itself. On the other hand, if REPACK (CONCURRENTLY) 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 table rewriting is not decoded: REPACK simply tells heap_insert(), heap_update(), 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 transact= ion is the reason that even the logical decoding setup does not have to wait for the transaction to finish. AFAIU the reason the snapshot builder needs to w= ait for completion of (non-REPACK) transaction started before SNAPBUILD_FULL_SNAPSHOT was reached is exactly that the transaction might h= ave performed catalog changes before its decoding started, so we do not know for sure if it contains catalog changes or not. > BTW, are we intending to commit this patch series for PG19? Yes, that's the current plan. [1] https://www.postgresql.org/message-id/CABV9wwMQkN6wOxMnd1h95eqpC7wEqivB= zsBzCp3VnxGFk%3DvDUw%40mail.gmail.com --=20 Antonin Houska Web: https://www.cybertec-postgresql.com