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 1wEkS8-004MDC-0t for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 08:58:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEkS7-001iTS-1Z for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 08:57:59 +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 1wEkS7-001iTK-0M for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 08:57:59 +0000 Received: from mail-yx1-xb12f.google.com ([2607:f8b0:4864:20::b12f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wEkS4-000000026aV-3UHd for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 08:57:58 +0000 Received: by mail-yx1-xb12f.google.com with SMTP id 956f58d0204a3-64eaf8aa893so2084034d50.3 for ; Mon, 20 Apr 2026 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776675475; cv=none; d=google.com; s=arc-20240605; b=IXKR2ZybPJIUGiTblVc+vmIdZGXH8V/hrDg63skxi8K6F31D/E2tc6NC5nm+L2J8HP fAIMQv4WHOjin9Q6JHQh+UBcaJwTw9TmKkOMTOJXgwrqtT9rKTEpdvpdDI0l0bStZFWn Yjtd7uM0jLbfiAXvtpcxR0oG/b6zUoU0BP/vtCXd6mk0IMzhbtQTSC0fF+jZZkNPdPZn +QmPSlYPJKAHNN19fqXQnCG2e6gpokoqx9TqcFoysf+FWi1uY9hIHFFDgF0uHWaO3JuV JJiT6FWvZuFwPmQp2YIe7jZnK2flqr7W9z8ldTvjsG0DzgqfRYPz264uD6nJ5mgBZKdb Q1JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=moC2HKfg8qsg+dLyAcJK8M5bmBzINjbmaSyv80KVvs0=; fh=B9yDRt5VClUf1sIPgwcNQA9EqGoD49QhefIpyGvcca0=; b=JanlWfcoZYcjb0/KkgSG4qE3cdsgd8vI372hlFOzyHU9blZiZLuNsVV3cACNCZGz4n LPkRnsHiVNydSq+0RS+pRIWnoOLH5n95ryNFScYAXobHdAPwYlj8TpOd32vgVMfqfC81 ZSpATSzGXruIurWE4nxMhNHdlBzVO/EN2n27xuzLZIxCj7P3Lt8Ob6YWSyl4aDeZ87iv VsmXc5yorGoo2B+MMJro8PkEeBxvtm4o/BZDkz3NJFheeg/+CBwHKe9ebf/x5o2mIM1S LqFZ6D5A3hWDAtfzMV4Nq43XGIwdZ4+ODgRROgQOncL5GZF6llsY5AJx5z1oE4QvoXdO ofAA==; 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=1776675475; x=1777280275; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=moC2HKfg8qsg+dLyAcJK8M5bmBzINjbmaSyv80KVvs0=; b=T+p2FvmVjxz1vISCr7OA5Vooa1XYoeosuQpI176cQZ5MXcU6QQQcunVQ7s7LWgm9Z1 t0HMLw4Vtdzik+MZ52YVIavCL4rBn1oOysQy8ugnJjDU32f28YyFtW2K5VQ3WynJdwQ5 zu6qYSBgxY87Z1EoQjINwdbzuzTxLbi1dL9aFMmkPNgXhIUK6do0hEOGU1saBQTNXqyn pB9m97JgSwA2oLrJnwPuR8sVwSyAh8QJQTq9DwU6hTZeiYhndlIS/hvZWKe7mPKoWDli e5wJCLTnfYQesE5DpOHYkGisdkWeySYLU0kyLfw/xNygGccRiY5+kVvWrGlyfpGXL10Z SIfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776675475; x=1777280275; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=moC2HKfg8qsg+dLyAcJK8M5bmBzINjbmaSyv80KVvs0=; b=PxZv7bxJ/Eqm4LnM6mXWqmuyh7BX0zV9o4VvG9/YpjNkp+8AxEYnOa69U9OlavWuZI LjbTgbDPzdzMNTj6vQWlrNSy5rFYmbWp2rZ0mGHOKzIVKmgC9xDXvB7KjxiI1u4uHkfH m2SrkfiFlumxpIA7B3/fmBYCyzAw7sOjy7JSmjs9U7C8uiAghubbu/a3n6gye/uNmK7y wDAI0bXIqG6hCcbBZ8BB+lTXIMMoYHOFOfngM2GG7+ix4H0TIgnStAYVU5JE07QRs0C1 d/y67hPJlEWzSV4REI0OoBJWmeE9mvHYWdgKokyFCzk8CHGtKulhovRmTA2k2o7ET4gl yQcQ== X-Gm-Message-State: AOJu0YyfxX/S7rv1vi5f17fqdvnFuKqcQHlOhDrmg3QQCUBIPchgCKCs uw7pY2/czz6aXsvJThNgKXka5+vNAfSn3aA3UEhfgZS08h6+Z/eZqEfvY3bOWfKTpmUSXOyRqhe mplRmy0hPGf5sClJGfzfv975t/Den7FsZMCD15hQ= X-Gm-Gg: AeBDiesWFjZakpfgUwwyInVdlS3wmcJx9OM576iGCQAZLAWHo57CXzPzlHKME72fTgQ VxrqALFGe8qLE06VHQnVyuz+vJTdDnn6hhUFJX+GIqJImNXuzxn9fBMCUvGX4Z7obZ50gSPul+d OaFSSDPiwxXb4rEb0qXAvwMtgChiws1i8RY1bjzgc2tr1ouUryIn2FW5KYrOevSba7o87zQ4nk/ xAacCvidQ3o/j5euEcVZwJ+O4VZFY96L+WHwdk555yGKbe5Js7s4LbUSJRt+1rx4dN7ISzHdXKx haLjxDMYintW8d5GVA== X-Received: by 2002:a53:a104:0:b0:651:b593:d3cb with SMTP id 956f58d0204a3-6531086a57emr8770792d50.24.1776675475035; Mon, 20 Apr 2026 01:57:55 -0700 (PDT) MIME-Version: 1.0 From: Lakshmi N Date: Mon, 20 Apr 2026 01:57:43 -0700 X-Gm-Features: AQROBzA-SsT0s8BnVR93fwQxvcCqmD3-JCk_R9bIo4ExKtraCAqj8JS_hseNAQw Message-ID: Subject: Fix pg_upgrade to detect invalid logical replication slots on PG19 To: "pgsql-hackers@lists.postgresql.org" Content-Type: multipart/mixed; boundary="000000000000924c37064fe07eca" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000924c37064fe07eca Content-Type: multipart/alternative; boundary="000000000000924c34064fe07ec8" --000000000000924c34064fe07ec8 Content-Type: text/plain; charset="UTF-8" Hi Hackers, 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. 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. 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. Regards, Lakshmi --000000000000924c34064fe07ec8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Hackers,

The PG19-optimized sl= ot catchup query uses a CTE that filters on
invalidation_reason IS NULL,= then cross-joins it with the main slot
query.=C2=A0 When ALL logical sl= ots 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 sk= ip those slots entirely --
neither detecting them as invalid (which shou= ld block the upgrade)
nor attempting to migrate them.

The pre-PG1= 9 query path does not have this problem because it queries
pg_replicatio= n_slots directly without a cross join. This may not impact
upgrade to P= G19 but will change the behavior for PG20 upgrade.

Fix by changing t= he cross join to a LEFT JOIN,
so that invalid slots still appear in the = result set with NULL
caught_up values.=C2=A0

Rega= rds,
Lakshmi
--000000000000924c34064fe07ec8-- --000000000000924c37064fe07eca Content-Type: application/octet-stream; name="0001-Fix-pg_upgrade-to-detect-invalid-logical-replication.patch" Content-Disposition: attachment; filename="0001-Fix-pg_upgrade-to-detect-invalid-logical-replication.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_mo6yhdni0 RnJvbSA2YTgwOTU4MjA0MzY0Yzk0YjUxMWU3NzI4ZjgzMjgxMDEzY2RiZjA2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMYWtzaG1pIE4gPGxha3NobWluLmpoc0BnbWFpbC5jb20+CkRh dGU6IE1vbiwgMjAgQXByIDIwMjYgMDE6NDc6NTAgLTA3MDAKU3ViamVjdDogW1BBVENIXSBGaXgg cGdfdXBncmFkZSB0byBkZXRlY3QgaW52YWxpZCBsb2dpY2FsIHJlcGxpY2F0aW9uIHNsb3RzIG9u CiAgUEcxOQoKLS0tCiBzcmMvYmluL3BnX3VwZ3JhZGUvaW5mby5jIHwgMyArKy0KIDEgZmlsZSBj aGFuZ2VkLCAyIGluc2VydGlvbnMoKyksIDEgZGVsZXRpb24oLSkKCmRpZmYgLS1naXQgYS9zcmMv YmluL3BnX3VwZ3JhZGUvaW5mby5jIGIvc3JjL2Jpbi9wZ191cGdyYWRlL2luZm8uYwppbmRleCA4 YzU2NzliODA5Ny4uMzdmZmY5Mzg5MmYgMTAwNjQ0Ci0tLSBhL3NyYy9iaW4vcGdfdXBncmFkZS9p bmZvLmMKKysrIGIvc3JjL2Jpbi9wZ191cGdyYWRlL2luZm8uYwpAQCAtNzQzLDcgKzc0Myw4IEBA IGdldF9vbGRfY2x1c3Rlcl9sb2dpY2FsX3Nsb3RfaW5mb3NfcXVlcnkoQ2x1c3RlckluZm8gKmNs dXN0ZXIpCiAJCQkiICBjb25maXJtZWRfZmx1c2hfbHNuID4gbGFzdF9wZW5kaW5nX3dhbCAiCiAJ CQkiRU5EIGFzIGNhdWdodF91cCwgIgogCQkJImludmFsaWRhdGlvbl9yZWFzb24gSVMgTk9UIE5V TEwgYXMgaW52YWxpZCAiCi0JCQkiRlJPTSBwZ19jYXRhbG9nLnBnX3JlcGxpY2F0aW9uX3Nsb3Rz LCBjaGVja19jYXVnaHRfdXAgIgorCQkJIkZST00gcGdfY2F0YWxvZy5wZ19yZXBsaWNhdGlvbl9z bG90cyAiCisJCQkiTEVGVCBKT0lOIGNoZWNrX2NhdWdodF91cCBPTiB0cnVlICIKIAkJCSJXSEVS RSBzbG90X3R5cGUgPSAnbG9naWNhbCcgQU5EICIKIAkJCSJkYXRhYmFzZSA9IGN1cnJlbnRfZGF0 YWJhc2UoKSBBTkQgIgogCQkJInRlbXBvcmFyeSBJUyBGQUxTRSAiOwotLSAKMi40My4wCgo= --000000000000924c37064fe07eca--