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 1wFTeT-005AmD-34 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 09:13:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFTeS-00Cd3K-2r for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 09:13:44 +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 1wFTeS-00Cd2o-1L for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 09:13:44 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFTeQ-00000002E7r-0w95 for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 09:13:43 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-354bc7c2c46so3253064a91.0 for ; Wed, 22 Apr 2026 02:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776849221; x=1777454021; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DJYxldnU1W0qj5AffonGwBW8zDSLjZX5hqydEqqGgtM=; b=o1lWaNBnHTQc6K3jdQGr/es09RuAxJAEKpa3Zj3dT/FZkiOaHIoBrAFN3WNDV8wDPt bVkmmkXBri5oOwZauMyug/DFKL20pCaznsdUsB0f0u1iaROeZK0acvt1eJKSb0WA9uUy u6JFfc/TpV+4yG7tnI5kyKIKzBMXYIpkEU0Q2mLBqgsFTM9CwFMxXRKkwX89hE6n8VFN mIxNWlBUj/NeibfJKRSenU+odrBbDsblIyT9iMglNwAGUAlG6vD7DFfTQRwRA2ChPItX t3ld40T0PeaRruGw7czmsniBLsHuEt2igVMZylZQvoq0Z7xmijn6Nx8viKinrOqVpd43 UN/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776849221; x=1777454021; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DJYxldnU1W0qj5AffonGwBW8zDSLjZX5hqydEqqGgtM=; b=O2/T7oPdBcfi1+/+yawL2Jk4fy7wIyqJq6kJAIQ9wrhCzuf+gHV6ixN41BvIJc1UMP IM8G4d5FLrrdbd02OoWIuOPgYD210zBzH4K0pdMwR3UBHHQnHWMuaPM76lji/FeBC/er e8bKJO/+D3vpoRzOtT3I/2xGGDjQyf2P0yZij+v2TsPWEmDAgWC0sSYfNt76UrifVr/P lzvnyMIq53TJClENE1vWeOOsaWl2Mn9ETfNgjSL6t3m8+PnrP9rBU7poNaRNc56dwo7K poRTjKxrkYd6dnNX7VBQsbc8oyUP3ldznbNJYW8Isuj9pcZFo092tyAU3vbcFF7rvQx+ E8Dw== X-Gm-Message-State: AOJu0YzL6qVVFSX9CTVqngz7DEvUyD7j5Ukxe3jQ4ANRtClfZFBGznKO qMLa3iwWByB5TDPlABX45KSm1wGrffgcRIop4cNa4QTA1nIved51y4D80L31PdQD X-Gm-Gg: AeBDieszVQQit2Z/ulEfZa0nsLIgoqIPFf4UICf559t5ut5FS0P9BBThAvLITf49DkR p+4c9eitXm7n3dVnZYWu6jcIovYaRbXcVbWrHQY6IE25BhWNcqWDelaYgCBkbRSAH7TNO1LFKdQ yIzAgNrB63ke0RTgsEobSyudptyY8j936KvzD92xblpamgx/cZqYEiTgsXCx+PFmoaaLRdTkzT0 ZKnd8a1iZ8wjYSeVmTZ50jJdtjv8vIMmr9bBomGUHwz7tbexyfid5BkuhPFdDUhCZNO5iMhsQge Y6tp0LLoe8KNVJe8IFRFJrX3TVBhTtT+9x3MpxQkVsj7zNw2VtL6hMyfCG80sICcePuUTYVlev/ YttOmtaMvLZEJ4hb/ZYAaQmX0K5V1GuwrVoeBXDrKrCijRhRBwSeZ+xEvefGCaogTxL9A+nzSXJ IREYkUYCzZkLDFa3BvNk/QL7lQj6CcuUtv33y/mvQUcg== X-Received: by 2002:a17:90a:102:b0:35f:b940:4e81 with SMTP id 98e67ed59e1d1-3614046f98emr13335937a91.16.1776849221133; Wed, 22 Apr 2026 02:13:41 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3614198f775sm19518571a91.16.2026.04.22.02.13.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2026 02:13:40 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Fix pg_upgrade to detect invalid logical replication slots on PG19 From: Chao Li In-Reply-To: Date: Wed, 22 Apr 2026 17:13:01 +0800 Cc: "pgsql-hackers@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <91589FA5-0AB6-4A71-BD6A-F206866FDA93@gmail.com> References: To: Lakshmi N X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 20, 2026, at 16:57, Lakshmi N wrote: >=20 > Hi Hackers, >=20 > The PG19-optimized slot catchup query uses a CTE that filters on > invalidation_reason IS NULL, then cross-joins it with the main slot > query. When ALL logical slots in a database are invalid, the CTE > returns zero rows, and the cross join produces an empty result set. > This causes pg_upgrade to silently skip those slots entirely -- > neither detecting them as invalid (which should block the upgrade) > nor attempting to migrate them. >=20 > The pre-PG19 query path does not have this problem because it queries > pg_replication_slots directly without a cross join. This may not = impact > upgrade to PG19 but will change the behavior for PG20 upgrade. >=20 > Fix by changing the cross join to a LEFT JOIN, > so that invalid slots still appear in the result set with NULL > caught_up values.=20 >=20 > Regards, > Lakshmi > <0001-Fix-pg_upgrade-to-detect-invalid-logical-replication.patch> This changes the inner join to a left join, which preserves the rows = from pg_replication_slots. As check_caught_up is intentionally a = singleton CTE because ORDER BY =E2=80=A6 LIMIT 1, so there is no row = multiplication risk. So, the patch looks good to me. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/