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 1w9g3h-001dq2-1b for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 09:15:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9g3f-007S9f-39 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 09:15:48 +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 1w9g3f-007S9X-29 for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 09:15:48 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9g3d-00000000sIm-33Ep for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 09:15:47 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-79ed2fc6ac7so25805227b3.2 for ; Mon, 06 Apr 2026 02:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775466944; cv=none; d=google.com; s=arc-20240605; b=PdenqhNMcO0cy3g7L3AmTiK9u7vZwbnrcYh76kVm8HSnV8CxurAIJ8kRbO4cXdln7r wiOixlbISESODVssCGB1m4sVxYlTXrmEVA8+r3YQtei++FjDx46KnybqPVRWbdVCyAB+ EPt9+RuAUq1X/1Wgr5QrBzHEBiLwW/w+EAbfPMExCvu1S2YZ9rnrfPG/Wq+wBGAFJrXn EFDszjS5rKoER3g8C8cq8fR3vdUz67FMTbc/FM2WTs4QM2AQnlK7gn4XRM3Hlrywjtiv dajEX8Oapv1/1Qd3AdGYz/jn+cvmSBO7qhsItLGk14pbYd44UlFC5m1VDj2mAJi1RXTQ QkRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=YDT0OMcm/aJR/6KLwtJbCXfOXJYo/nK79POAZM+Nz84=; fh=5lk2VAtL5+703V6mBcHYep/nXpLPoSiN/8XsnRjAIKQ=; b=J5PzXUa51VCusdaxbchbf4Az2q/AzwVI4h9EQGprtUwtd1fWpP7pggjTUJf4WYGf32 8bucTH2OiwwTxybPx4Gj/vDuV1lH3oWKQ1xOj0lOGBM5Cery+gydS0ckwOLOm6N2lMqR 4WQhQAHWaVkZSkcQjFR5fn9kH6Qu0FTZ5ZJL8UORsM9hVOc6n5yArGz3xSUZsihFxwLP raOm2WtFXv/o7TxUWbZu/S2VZXVF8LXVCvburket8xNP1PnAgj1mUO7Uq6ur4l8k748C YLh7oGvS/zceeHtmZotCEZZzO7XkteToPs5sp4EfOW1nq3LPkAfzWebHnzxP+wzuOYDW adjg==; 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=1775466944; x=1776071744; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YDT0OMcm/aJR/6KLwtJbCXfOXJYo/nK79POAZM+Nz84=; b=ntRybQzMXyVfk0C2ppyLK6veTJbl5k816q/g56snZ9dEQuPqePUftP6L+G6tKX85kr SWDruTYwxeS5ll0dpUUFUAt85Jl+tNmoAjJvOgBMDVJL6tIjwX34uf1Hh1g4NTgWkkca zcQAN+BgsUvAqZbVXqbgCL/hwSjnN8UxRChPyHoyNHl9bQLm67tkKoi3zyuvv49AwNOw BDitaazEJwfDsq54OMS/ZDuf2AJRtsyzFBs0SBs7nKT4HZST/Odmu3XsWPlJAikxNuB4 0VBwFj5gNwAcH5jG29tqL3Wws3Mdgb2QrbtaQKkdY8AHWjLHrEObBemCEomLd2WcVd8b l9Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775466944; x=1776071744; h=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=YDT0OMcm/aJR/6KLwtJbCXfOXJYo/nK79POAZM+Nz84=; b=PAqa4uG4ZK4K5JdNWbBd0MuwJqelKuMLKNglwwGncL0VqhD5szqMCxmJ7ydVzefGIc kKMXc4ueYNE+UFCr6gjRc5fO9A97+XEwuJn6rM6tedyCfevcGhJ5Qv0PvDtLuuY4nhHZ UQzQN3aZ0oUG3uOtcLBkIvNS9JJEgP/soWOUM7Wo7zF/W06hGWkJ3gtzgwALYArgoEnH 3E8A0JdyHishcUK468/MCTYofDFGNMTTri8sYQlX9aDi7OGsmHhRuoztioHlkwZl0hAj qFiYEIRQjG6MjqiJfemiJj0Ut565qkUAKziRninpKK24eWUWpdBvbMbOtHw2+4dn5mSU C5+Q== X-Forwarded-Encrypted: i=1; AJvYcCVUaHqJlEU7wK9lyQ5HYANppE8p9exbCFc75Rl5thi2qz4aZStfitx987i3HBOrC1S4sCS1yVail6Jeb/Bm@lists.postgresql.org X-Gm-Message-State: AOJu0YxKY9heq+vGX67h/lYxjpDx0lPrLHxzspPIIAtEjwCa4ELewXzp GJrdhAKH/Q4sElQP37JZIUfqIYyMUeZN1YSdZnY3C7OTy0ughjEpqcC7Fvyy9HROjOatHVllVrS WjvqFnQpD5QBRxqqheJjqN+LKI6j+cMg= X-Gm-Gg: AeBDieszgqQ/3SIEp3uxnBYMCMZDuU9FqDCB2/fVKTIBzcOTEIY67tlhjE8CKWZiO6D 575RCaJ0HInXE4llWcVxta4Ca0kqjbWaOJqf8AB/Zy157zSyw868SgadbYnpvdIIP8ZAIAT1Bqe BmJ3Y7ncf8MNUYtzzhNvBHZrXj7YggWzE9giv3wVWNesxT86CFTTUMGjOBGhGwHRvS/3zvMwrtt VRCVwTJjVk+VJuQLbXyxyapVg2LRxy7XIvi75vCHPYXzwKIM3GL3KaVf2jrDSDThZ7JMQVHwLiI A+pChMQH X-Received: by 2002:a05:690c:19:b0:79a:d43a:11f0 with SMTP id 00721157ae682-7a4d6447cc6mr122238077b3.5.1775466943803; Mon, 06 Apr 2026 02:15:43 -0700 (PDT) MIME-Version: 1.0 References: <202604051852.qfdnfvemfkd2@alvherre.pgsql> <202604052035.il2hp2wze6pz@alvherre.pgsql> In-Reply-To: <202604052035.il2hp2wze6pz@alvherre.pgsql> From: vignesh C Date: Mon, 6 Apr 2026 14:45:31 +0530 X-Gm-Features: AQROBzB8rBQRISVX_vBlwQ70eDi0x8nry-tOyHunXVQgu53j2xAa1ibrthqAM7Y Message-ID: Subject: Re: Adding REPACK [concurrently] To: Alvaro Herrera Cc: Antonin Houska , Srinath Reddy Sadipiralla , Amit Kapila , Mihail Nikalayeu , Matthias van de Meent , Pg Hackers , Robert Treat Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 6 Apr 2026 at 02:12, Alvaro Herrera wrote: > > Hi, > > So here's a v55 version of the base REPACK patches that I'm feeling > comfortable calling very close to committable. I'm going to give an > additional read tomorrow and maybe make cosmetic adjustments, but there > should be nothing substantial. Of course, the subsequent additions in > the other patches of v54 are still in the cards, and they are most > likely essential. Few comments: 1) Can we add a comment why we should error out here, as repack concurrently requires this whereas repack does not require this check. Even if it is required for decoding can't it be handled by replica identity full: + /* + * If the identity index is not set due to replica identity being, PK + * might exist. + */ + ident_idx = RelationGetReplicaIndex(rel); + if (!OidIsValid(ident_idx) && OidIsValid(rel->rd_pkindex)) + ident_idx = rel->rd_pkindex; + if (!OidIsValid(ident_idx)) + ereport(ERROR, + errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("cannot process relation \"%s\"", + RelationGetRelationName(rel)), + errhint("Relation \"%s\" has no identity index.", + RelationGetRelationName(rel))); 2) Do you think it will be good to add a test to simulate a case where one of the swap_replation_files is successful and a failure after that. We can verify that the oid should still point to old oids: + /* + * Even ShareUpdateExclusiveLock should have prevented others from + * creating / dropping indexes (even using the CONCURRENTLY option), so we + * do not need to check whether the lists match. + */ + forboth(lc, ind_oids_old, lc2, ind_oids_new) + { + Oid ind_old = lfirst_oid(lc); + Oid ind_new = lfirst_oid(lc2); + Oid mapped_tables[4] = {0}; + + swap_relation_files(ind_old, ind_new, + (old_table_oid == RelationRelationId), + false, /* swap_toast_by_content */ + true, + InvalidTransactionId, + InvalidMultiXactId, + mapped_tables); 3) I'm not sure if this change should be part of this patch: diff --git a/src/backend/storage/lmgr/generate-lwlocknames.pl b/src/backend/storage/lmgr/generate-lwlocknames.pl index b49007167b0..2e7f1054e62 100644 --- a/src/backend/storage/lmgr/generate-lwlocknames.pl +++ b/src/backend/storage/lmgr/generate-lwlocknames.pl @@ -162,7 +162,7 @@ while (<$lwlocklist>) die "$wait_event_lwlocks[$lwlock_count] defined in wait_event_names.txt but " - . " missing from lwlocklist.h" + . "missing from lwlocklist.h" if $lwlock_count < scalar @wait_event_lwlocks; 4) Can we add an example for concurrently in documentation 5) Typos 5.a) "jsut" should be "just": + * operation to avoid any lock-upgrade hazards. In the concurrent case, we + * grab ShareUpdateExclusiveLock (jsut like VACUUM) for most of the 5.b In commit message "intial" should be "initial" While the "concurrent data" changes are applied at specific stages (we cannot do that until the intial copy is finished and indexes are built), a background 6) This includes are not required in repack.c, for me it could compile without it: +#include "access/detoast.h" +#include "access/xloginsert.h" +#include "catalog/pg_control.h" 7) Can you check if the copyright year mentioned for the new files are correct, as different files mention different years like: /*------------------------------------------------------------------------- * * pgrepack.c * Logical Replication output plugin for REPACK command * * Copyright (c) 2012-2026, PostgreSQL Global Development Group * * IDENTIFICATION * src/backend/replication/pgrepack/pgrepack.c * *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- * * repack_worker.c * Implementation of the background worker for ad-hoc logical decoding * during REPACK (CONCURRENTLY). * * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 1994-5, Regents of the University of California * * * IDENTIFICATION * src/backend/commands/repack_worker.c Meson.build file: # Copyright (c) 2022-2026, PostgreSQL Global Development Group Regards, Vignesh