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.94.2) (envelope-from ) id 1r12Rk-00917h-Q9 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Nov 2023 10:39:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r12Rh-00CwL0-Og for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Nov 2023 10:39:33 +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.94.2) (envelope-from ) id 1r12Rg-00CwIf-W9 for pgsql-hackers@lists.postgresql.org; Thu, 09 Nov 2023 10:39:33 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r12RZ-004ixe-Io for pgsql-hackers@lists.postgresql.org; Thu, 09 Nov 2023 10:39:31 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 7C7965C0312; Thu, 9 Nov 2023 05:39:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 09 Nov 2023 05:39:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1699526363; x= 1699612763; bh=d7mzSrzrBucGjvG1bSN5gaQko0Kv5EOVpj/SE1mgwOw=; b=j ZszEcKvvqp7CxWnLrowR7wuxsUL+0xkEP9WFDdv8Zj9lqwnvN5Ft7LlQn/5B5XVs k9cG5fffwM0dk7TRZ3vQowyzzjrzpy51EyaOr7YFri52YfbaWeL7CbyU4OR0O8/f d3iR7MgRv0SA+6f02pnIxb6xfMe0FWytIr10qfLwP7rrwLUek/mvvR2rx1/SLb1S kdaV1nwzLoPh8+5EJDPUuFCKuRM4JbA6CYT/hNgFv+Q3+YvgDvBkb1vYLuq07r3s z9Z1bZSZai3rBdnmggcvGKfVJ4k8YEmvKO6TSZ0SUik2+6vCzVq6yCnaz9w50Qxb f/5DClgwls3vwIaj5cptA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvuddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehtke ertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedvkedtffduff dtffffheffhfejjefhgfeiueeukeejkeffgfdufffhudffffeuveenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhr gh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Nov 2023 05:39:23 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1699526361; bh=WGqJCQg/O93qx5PbYrfnvhaRyzzIGDAqNKjeV30RY8g=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=EfiKJGZe0wBJPsYkda5M/LoF/ZgXWWsDkTRl6Pnl0Euxlak2x4YYu+SR6SqPiD2V1 YJnyaKgksMWds9UAuAtzmKR2QFqP8cKPsJ8IsHUkkPFyRLfdv73AuYDFXwrfQCmIB+ 2PwE3LOfbvg4B4XuuC5V4Atk6udWLQ4COLWxV6/+C3plpyaaH5YIVTDMgovGqKCJba AGMjadJRJT3Fxza3rAL2sAX8+OqSG0Ab1xUg6lUQ8z9/mWxttGBUidlowlL9Wpd8TU +DXeCeeQHkxS7HgPH8HoON1AlMrviztCkBD3J5LGG3gGhGhsO0+qtg8sisdIeAf1ts suAVMvy++PtoA== Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 25879C1; Thu, 9 Nov 2023 11:39:21 +0100 (CET) Date: Thu, 9 Nov 2023 11:39:21 +0100 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: smithpb2250@gmail.com, bharath.rupireddyforpostgres@gmail.com, amit.kapila16@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: A recent message added to pg_upgade Message-ID: <202311091039.of6jf7bs3cjd@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231102.115834.1012152975995247837.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Nov-02, Kyotaro Horiguchi wrote: > diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c > index b541be8eec..46833f6ecd 100644 > --- a/src/backend/access/transam/xlog.c > +++ b/src/backend/access/transam/xlog.c > @@ -2063,6 +2063,29 @@ check_wal_segment_size(int *newval, void **extra, GucSource source) > return true; > } > > +/* > + * GUC check_hook for max_slot_wal_keep_size > + * > + * If WALs needed by logical replication slots are deleted, these slots become > + * inoperable. During a binary upgrade, pg_upgrade sets this variable to -1 via > + * the command line in an attempt to prevent such deletions, but users have > + * ways to override it. To ensure the successful completion of the upgrade, > + * it's essential to keep this variable unaltered. See > + * InvalidatePossiblyObsoleteSlot() and start_postmaster() in pg_upgrade for > + * more details. > + */ > +bool > +check_max_slot_wal_keep_size(int *newval, void **extra, GucSource source) > +{ > + if (IsBinaryUpgrade && *newval != -1) > + { > + GUC_check_errdetail("\"%s\" must be set to -1 during binary upgrade mode.", > + "max_slot_wal_keep_size"); > + return false; > + } > + return true; > +} One sentence in that comment reads weird. I'd do this: s/To ensure the ... unaltered/This check callback ensures the value is not overridden by the user/ > diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c > index 99823df3c7..5c3d2b1082 100644 > --- a/src/backend/replication/slot.c > +++ b/src/backend/replication/slot.c > @@ -1424,18 +1424,12 @@ InvalidatePossiblyObsoleteSlot(ReplicationSlotInvalidationCause cause, > SpinLockRelease(&s->mutex); > > /* > - * The logical replication slots shouldn't be invalidated as > - * max_slot_wal_keep_size GUC is set to -1 during the upgrade. > - * > - * The following is just a sanity check. > + * check_max_slot_wal_keep_size() ensures max_slot_wal_keep_size is set > + * to -1, so, slot invalidation for logical slots shouldn't happen > + * during an upgrade. At present, only logical slots really require > + * this. > */ > - if (*invalidated && SlotIsLogical(s) && IsBinaryUpgrade) > - { > - ereport(ERROR, > - errcode(ERRCODE_INVALID_PARAMETER_VALUE), > - errmsg("replication slots must not be invalidated during the upgrade"), > - errhint("\"max_slot_wal_keep_size\" must be set to -1 during the upgrade")); > - } > + Assert (!(*invalidated && SlotIsLogical(s) && IsBinaryUpgrade)); I think it's worth adding a comment here, pointing to check_old_cluster_for_valid_slots() verifying that no already-invalidated slots exist before the upgrade starts. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/