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 1wNQ5i-000nMT-1H for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2026 07:02:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wNQ5h-00BCGw-0M for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2026 07:02:41 +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 1wNQ5g-00BCGo-2J for pgsql-hackers@lists.postgresql.org; Thu, 14 May 2026 07:02:40 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wNQ5e-00000000Wgz-0nDx for pgsql-hackers@lists.postgresql.org; Thu, 14 May 2026 07:02:40 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-393d07e8938so69437181fa.2 for ; Thu, 14 May 2026 00:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778742157; cv=none; d=google.com; s=arc-20240605; b=INS6meYOrzNLpVHb24qJ5nOuQh8qTfjO0+5kIgAs8EPudRxAast/tRd9D/h0Pu1Lh/ d8n1hwqYTGQeN2/VdSC3ldkuJ1EQPb2s8KccKVmtMWE3wIm0yxbgQTA3r9+0vGSW1XYx d1WEi5Gg78IdGfcMW64cjU88PGjqfen4iaYsWrrNoEC5/FtBHvGW5ViOn3Wb1zQCZ9SO frVoBHvtraLB7HhpQu1c+xqHhHycoIX+8IXtY7mGNCKjiV/rhpDqPzIJv3YZoT4Z5t0r cpLU3v8VR5oULFL8GsYJoSnECckchkhmrVO95bbNI0umxdEIssEjVzXd2vpsZ8/warPr 0XJA== 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=exAfjQISVXSyy9ZoyCbWvPy7Pr3JHFEN7GQCVnxdWXc=; fh=cJ7+HJkv81aYlt4849+7TMSCCIn4DHkGA2TFE7rKliQ=; b=N8sN59ziFTAMZC3pMkM9HD0WJwq1IS/dM6LaeLvXCioNXQzEr2+lVZ2TPrd9CzKjxa AOVHyZ1IEIfP/fJEnFim/xx7tBIjjfVEMpebfiQxFlyUu8WQsKLhggdaPMwGi5pPb+7Z PVZR1dUiG9pDd9RxOqn+CM/cvCfVLJFXo5vwvzADVkwVKEDpF0eG8Tfeyc59LYwI31Vo stxEI+i0bOptg0TkMluBDz5+Xbe0nLBqc0gWq8W3cyuG5SLucKX7i2L2GHukXSznJ8Ni /Yhue+efYZkqtEYllcq3DdOdkJkmdDpn1ka0Wj2A7Qm8hy7wO5/hlKgt5A8UKHahE/Tu Bs0Q==; 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=1778742157; x=1779346957; 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=exAfjQISVXSyy9ZoyCbWvPy7Pr3JHFEN7GQCVnxdWXc=; b=AmB79XLFb2ln67VT/JvhOpFLJp5ZguLCj4F6e42VOL70Ge323Z+eM8gb5iUY6xtguV tSEgrqoU1tYT4SYpe3NO/PBfSWkej9o1UIN1RwGoB4co/PiiOhOgWTU6L+dN86GoFU/K eLhpUQ0yp68oFb3GpTeKtaJg8LVqfK+za5nznRM65UiLwVyV0OL+YsQqaay80G03423y 1k7LRUI5TetIhkkoZ5aUvSa1vqGf43u6e8tdbKYrDEbrJgLTq89g5DublMqBow2lvnpt Wt9Hq4xYz8eoUhAGwkbLc+UAkWT5e1H0gUzsmVjxq6Px/XcEiZ17cBl10liiA1T7hUnL vh0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778742157; x=1779346957; 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=exAfjQISVXSyy9ZoyCbWvPy7Pr3JHFEN7GQCVnxdWXc=; b=pBlMPKf27c++dEj6H6JMU0bBJ4/72VJ5pNwHYvftHuHPbHPRAmKZxS2RymDeaK+jPZ LpVt7hypXwdcrS03ngiftXOdMqWVDmH5TSDKx3wOyScx7vQ3lYYfiErh6KY3In1VAyvH BC3eSV5yYrnGRevkXw9ctVM64qzsug0CrdfQhFM8STBY+An3UcTK77NPXPaiy65sLju1 f18TTQBkj487VM1BCDs9AfElueXwUNHRROEZeWyuJjO6/+ZOHVDFDBgNIYv3TR8dHCos zsPSlaY2TyGcHmvyXurTmRG4pfFhxGjGNzMzO2n24ESHpNu5pVTlUAFkclFi3Uj8OUio ib7w== X-Forwarded-Encrypted: i=1; AFNElJ9VVdaytio6p8SLW8FwEspz35eAVsjdIFJenU15CochjjSOEzRPFuIDTV+lH9q7Uq/4kzpI+yJoMMY12LQ4@lists.postgresql.org X-Gm-Message-State: AOJu0YxK5542AP/CWeeLXVn+z5HaXevFELWLGyy9UFoyF0ywiT5EmaL8 IhowojeMEunDowO9GO4+DjKdEvomhIgh/KC+FiDIfHUgUKZ5l72xFuBSYILdQsFfrfitfGAGsgU 0YPzIwt0EAKlGmU1odF4xR4sMs1XZSI+Jb4enXHw= X-Gm-Gg: Acq92OH3LWV4Z6zerD0oszS5o4ceQe6qrfZuKh4XeXm0R+ksqj9ELaIPAiqjHR4cBKh QvLELWBZIkHUIOQ+uz5hebkn50+Hpidmi7y3ZZ6zS87MBponPo3nXt9A6lI/yFozj5d3KrvH6+e fLLPMa3JBKPaBgZW1+CUuMeHwo/DSJ962bf58z+WuHYdYhVzmM2DDAG1C4AquIweBgeDnVxyops 4jSXGuf03Fn5AbOP8L99f/OohIerAU2fFnIFMnojtvUHEoVeFDe4Yi/eVjO5jaS+xM0m362EYTT +ngFe33vXpQKJJ1nxkjhYXMKW5zvSoBhjSp5xsRli5q7RWgNLHeYQVkA8ATkXwq06ca5HN6uHRc qkMSBSJ+sKg== X-Received: by 2002:a2e:bc10:0:b0:393:856d:1691 with SMTP id 38308e7fff4ca-3944eaed9camr21155821fa.27.1778742157128; Thu, 14 May 2026 00:02:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Thu, 14 May 2026 12:32:25 +0530 X-Gm-Features: AVHnY4Iht55B1hudTHBl3yfoaW0vkeFyhlWN13E3Ak3DcE5nomId5_YpG5XhXoA Message-ID: Subject: Re: Adding REPACK [concurrently] To: Alvaro Herrera Cc: Antonin Houska , Mihail Nikalayeu , Andres Freund , 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, May 13, 2026 at 10:28=E2=80=AFPM Alvaro Herrera wrote: > > Hello Amit, > > On 2026-May-13, Amit Kapila wrote: > > > So now the question is where do we go from here. I am not confident > > that the current code to achieve db-specific snapshots in logical > > decoding is the best possible solution both because of the drawbacks > > (like we won't be able to enable this on standby) and inefficiencies > > pointed out by me in this and previous emails in this work. > > This is a fair question. I don't think we have time to go much further > on this aspect before beta 1, so we either accept this patch, fix the > inefficiencies you pointed out and keep db-specific snapshots, > I don't think it would be easy to address these inefficiencies before beta 1. The root of those inefficiencies is that the patch reuses the cluster-wide running_xact WAL infrastructure to log db-specific running transactions, and then tries to feed that into the existing snapbuild machinery to reach a consistent state. As another example of this mismatch that occurred to me today: in SnapBuildCommitTxn, we are tracking the committed_xip array for all cluster-wide XIDs, even when using a db-specific snapshot. A db-specific snapshot shouldn't need to care about XIDs from other databases. We only try to take care of it in one part of the system where process running_xacts record. I admit that I don't know at this stage what exactly we should do about it but all such things deserve a discussion and careful thought. The broader issue is that the entire logical decoding mechanism is designed to process cluster-wide transactions. This patch tries to bypass that foundational assumption, but only during the initial snapshot construction while processing running_xacts record. To be clear, I am not against the idea of db-specific snapshots to enable concurrent repacks. My concern is simply the time required to get the architecture right. In its current state, we need more time to carefully consider how this db-specific concept interacts with the rest of the logical decoding machinery, which is built for cluster-wide records. > or we > revert db-specific snapshots and go back to the standard snapshot-taking > technique for REPACK in 19 and see what we can improve for 20. > > Now, the worst consequence of reverting db-specific snapshots is that > you will only be able to run REPACK in a single database at a time > (because any subsequent REPACK will have to wait until the first one > finishes before being able to get its snapshot). In most normal cases > this is probably not a big deal. But if you have a multitenant system, > and you want your users to be able to run REPACK on their tables, you > may be a bit screwed. So I hesitate to just go and revert it without > offering those people any alternative. > I understand your point but I feel we can extend the current feature in future versions to address such cases (allow REPACK CONCURRENTLY on tables in multiple-databases simultaneously). For now, they may need to rely on REPACK without CONCURRENTLY option, if they want to use it for multiple databases simultaneously. > (It's also possible that being unable to run more than one REPACK at a > time is not so big a deal. After all, it's supposed to be an infrequent > operation. And users probably don't or shouldn't have multi-terabyte > tables in multitenant databases anyway.) > > I'm not sure I understand the point of the standby. I mean, you can't > run REPACK on the standby anyway, so I don't see this as a very > problematic restriction. Do you have other reasons for wanting a > db-specific snapshot in a standby? > We are exposing need_shared_catalogs as a generic plugin option, defined as: 'it can be set to false if one is certain the plugin functions do not access shared system catalogs.' This implies it can be used for purposes other than REPACK. For example, one can imagine a single-database audit plugin that only cares about data modifications within a specific database. By setting need_shared_catalogs =3D false on a standby, it could reach a CONSISTENT state much faster, perfectly serving its needs. While such a plugin might not exist right now, my broader point is this: when we expose a generic facility, it can and will be used in ways beyond our initial core use cases. We should try to ensure the design doesn't permanently preclude such extensions. With the current design choice, we are painting ourselves into a corner where this feature cannot easily be extended to standbys even in the future. --=20 With Regards, Amit Kapila.