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 1wLY43-001r1n-0i for pgsql-hackers@arkaria.postgresql.org; Sat, 09 May 2026 03:09:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLY3z-00CA4p-39 for pgsql-hackers@arkaria.postgresql.org; Sat, 09 May 2026 03:09:11 +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 1wLY3z-00CA4h-1z for pgsql-hackers@lists.postgresql.org; Sat, 09 May 2026 03:09:11 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLY3w-00000000vJr-2ZVN for pgsql-hackers@postgresql.org; Sat, 09 May 2026 03:09:10 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-364f7c42c62so2342875a91.0 for ; Fri, 08 May 2026 20:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778296148; x=1778900948; darn=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=mkdYiZWgyZmUgof+bBQUxoX/flpnyybMoclsz49MCzs=; b=GllKhJxN7iuB5d7tYSyf/7slK0Wz+/YI3BA0AZb84NAY1IEK4fEThryBVJQsm9qzpX Kxt1uMfWKOuVrTW/hmsQZcOCcp2BTGzF6voYbhcD0fdWytm4BJNsdHbjzXRfIOaMbWXQ op5XRl+88xy1T2Wsz2Rr70ptSfVycGxCzJDRuml7x/zk05rkKdzDl/NUzCiOsTPu9imr wakzxdkR3eVRluPdt/FweGuNeiYMYIR5gumjud5iB1GnqUVS9VWY0nzmY6IKiDgsfHhp a3KcgPNJEYdqLScmj5+4C+Qr63cI0viCAhVOv4cP8AftbB6l6h0D/0oRsLB8gRAHbTWf nKtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778296148; x=1778900948; 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=mkdYiZWgyZmUgof+bBQUxoX/flpnyybMoclsz49MCzs=; b=ifvY3/LO/b9GFBOuHR4oO7wHUZxgCx6q64lxKakSgQRfIg42RI5RmSl0CKSToITD/E yhlNmkndez7IrGF1IYWIUfaO7fFZBunDJIAKAl9weR+2rcSg00gQcmO5RN1PDYOOaVWr PDR0FMJzfmcJSzdy4I+wSB+r58K1S5MU6klk0272L1Esu9Wok4bK4FrEpKNvLgB5QcAM iBK8Gut3WMviTqKrT8DCHiKw1Ld7HG+sRA4wCrwvya8NYiTJeiT22hpXQSDdOcRw/rvI 10lPK9iyr24N+45PunGF3WetgvIM5168BlfSXRqtLITBI0yq/3T9wJ1zF4Q6enJ4Tx1Z pVSw== X-Forwarded-Encrypted: i=1; AFNElJ8XqByRE3iBRXkGpLRq6nBdf4jQN3WSgUmdzpMZTgbJ53yV0GaK8MGBAEBuCSFcsC3eHcsgS+G2jtZt5RCp@postgresql.org X-Gm-Message-State: AOJu0YwihIMx/NfaJt1Nl+Svcr8Jg68+SX+1NVFRUKpa33CQvNJQBTKh a0bLtsOMfy0PxFE5HfIcVErmvaY51wqmzyrAp2bfUtR+gn9rcTKEskHH X-Gm-Gg: Acq92OH4+BUGD7s8Y22VNaXIxGT3jkz6mjwSOkwYs1zy8pRhMSuBns7ZCNDjTgE2b1a bZCqcMDyd3Unqsda40SRECQ+RsGdnu6GVYFsgcJzRlJXLOdIE15KMCbVpcJ7PWHLbjdOlk8vbr5 G1ObDo0VSXe/juzQE7iIxfy92BE6d/l1mfj4ipDJcnBPbJwwrHtU/QwyexH3wdEo7erhmOaQbJk OLh2I2OtfMe+TN9pQK6KsNYiuV6kyQ9Fxma2KjGzeB7/B/3iCLUqp3WsHY4P7reYN0tuXk92Wix W0Dg1lN/OerscR3flJPtmU+DmLihshQ1JKCgUSkDKx/vPEeFMKVAchLcVQYOs1hZjZzHirmVO6S N/WRMJK6h/ZTXFAKNlTsgLsiGA3CGNCJzf9zBXXciM4ZaSjw0OREPRC23+UzjhQa400OKV3CInA Pd0ffJmeIdOfKLuUaWc4KpdrVHpnVC/2g= X-Received: by 2002:a17:90b:5683:b0:35e:576e:5bc with SMTP id 98e67ed59e1d1-365ac79c531mr16011071a91.25.1778296147795; Fri, 08 May 2026 20:09:07 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-367d63dffe5sm626962a91.11.2026.05.08.20.09.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 May 2026 20:09:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server From: Chao Li In-Reply-To: Date: Sat, 9 May 2026 11:08:28 +0800 Cc: Zsolt Parragi , "Hayato Kuroda (Fujitsu)" , Ajin Cherian , PostgreSQL-development Content-Transfer-Encoding: quoted-printable Message-Id: <705148C3-519C-45E7-9EA8-48D9F3B79B06@gmail.com> References: <960DD2C4-A22C-463A-90ED-86E0FABD8D20@gmail.com> <8B38AFCA-7FFA-44CF-B9A8-81BDCEAFB224@gmail.com> To: Jeff Davis 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 May 9, 2026, at 09:01, Jeff Davis wrote: >=20 > On Wed, 2026-05-06 at 15:57 +0800, Chao Li wrote: >> PFA v3 - addressed Ajin and Zsolt=E2=80=99s comments. >=20 > Thank you for the report! >=20 > The proposed patch seems unnecessarily complex, though. It seems too > easy to add GetSubscriptionConninfo() in the wrong place and end up > with another problem that's not easily detected. >=20 > Can't we just do something like the attached? It's easy to explain at > the call site that, when changing to a different server or using > CONNECTION instead, that we don't need the old conninfo at all. >=20 > I included your test case in my patch, and it passes. >=20 > Also, Hayato Kuroda's report was an issue also because the error could > be thrown even if slotname was NULL. Patch attached for that, as well. > Thank you, also! >=20 > Regards, > Jeff Davis >=20 > = Ah, I see. You added a new conninfo_needed parameter to = GetSubscription(), which separates the decision of building conninfo = from the ACL check. Cool, I believe this is a better approach. So 0001 looks good to me. nitpick is that conninfo_aclcheck is now only = meaningful when conninfo_needed is true. I wonder if we should mention = that briefly in the function header comment, or add an assertion such = as: Assert(conninfo_needed || !conninfo_aclcheck); to avoid possible = misuse of conninfo_aclcheck in the future. For 0002, I have a doubt. Now conninfo is built only when slotname is = not NULL. But after reading through DropSubscription(), I am not sure = conninfo is strictly tied to slotname. For example, this fast path returns only when both slotname is NULL and = rstates is NIL: ``` /* * If there is no slot associated with the subscription, we can = finish * here. */ if (!slotname && rstates =3D=3D NIL) { table_close(rel, NoLock); return; } ``` That seems to imply that even when slotname is NULL, rstates might still = be not NIL. Later, if conninfo is not NULL, the code connects to the publisher and = does some cleanup work for tablesync slots: ``` if (conninfo) wrconn =3D walrcv_connect(conninfo, true, true, = must_use_password, subname, = &err); ... /* * Drop the tablesync slots associated with = removed tables. * * For SYNCDONE/READY states, the tablesync slot = is known to have * already been dropped by the tablesync worker. * * For other states, there is no certainty, = maybe the slot does * not exist yet. Also, if we fail after = removing some of the * slots, next time, it will again try to drop = already dropped * slots and fail. For these reasons, we allow = missing_ok =3D true * for the drop. */ if (rstate->state !=3D SUBREL_STATE_SYNCDONE) { char = syncslotname[NAMEDATALEN] =3D {0}; ReplicationSlotNameForTablesync(subid, = relid, syncslotname, = sizeof(syncslotname)); ReplicationSlotDropAtPubNode(wrconn, = syncslotname, true); } ``` So with 0002, if slotname is NULL but rstates is not NIL, it looks = possible that we no longer build conninfo and therefore skip the cleanup = on the publisher side. Best reagards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/