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 1w75vH-004xEq-34 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 06:16:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w75vG-001esg-14 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 06:16:26 +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 1w75vF-001esX-2x for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 06:16:26 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w75vE-00000001l99-1Zxr for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 06:16:25 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-38bcda08c76so32053651fa.0 for ; Sun, 29 Mar 2026 23:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774851383; cv=none; d=google.com; s=arc-20240605; b=W1xIQGPprEwo+uphFCejaFTWw8zq3C9wONHuaYuhqsGNfXyJgoAPt5Uq/5xSXTas3N pZXue/zw46eyxpt2NGiWyI8SbZ3EzzmEJl9BeVNZDueXi7Gsp2i3TbzffiUOaweWEEsz 8vw7GYdH6+hUdfTPuoQCHYxCbud3+BPz7c1CPLJWVodpydnsGhQ1l/b4tnPVheSVPnMu LjlHwR8H8XfaqpQ97+UHbvpSY5M0A7HRNyXWKYwJekFsD9Qt505L5uVnkGNc7UvMgRGC +JvU88YPZ5MSG6u2mAJOqR1nWiVT67tpKtWzVvRlJSjK5tofQfzAxFJjCUnR0ut4pOWU gCVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zv/cdNKG/SLoH2OSXmBnp/b8qcwYWkoxiHOGhZKCyKU=; fh=difWPyZhf+FMfWnUHiBJsrLSKQJL23D1+3HP+YAZNos=; b=T4xYbuUMc0JEpD4GFuEcAMVQ8JuIBydBD4Mn9dfvfJFaL92BZaoGXsnj7zvL2WOtL5 xGZLfGplKEXNXRXlkCSQaLR/0UONHAYL5jtWu5rPeXid7JlGylWXDJNNGA/q0dci4n0k Gu31rGMzmsrmM1wfI+aKajmmjUCdTAxs/jvEXceC8usM3fRjzaihq5m6JuGqCmsBU8Kk 4bOIg0ciNZVwUQdIHULv0+eUZdrBQzBVcb7QJC53Bu2BCVLFNqKEB0WkiQqf7I+ILb8T W3EU5xpZJJj1fyjo6d2qjSLtxlvak/yoYVN7CFcbUpFCW5rK8Mx1FmlJNDpbEW5Z1RZh 8ADA==; 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=1774851383; x=1775456183; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zv/cdNKG/SLoH2OSXmBnp/b8qcwYWkoxiHOGhZKCyKU=; b=ohRDDLmALDSpCL2zLmv8P0IUvuMTPL0DS1MTIIhYgdd2P9ham7AhE3TdrS3EDIXtbF KdF4gcIz90VK260/7lvfj4h9xvPdLZpPSxxBN+daVqf9Tl4hsgtdqfjfkyWtLg+wlj8M AWAJWin8Rt9VRwH/W+Zo2bPzqEMIGUY7D7XSV4gkH44FL0hDGL+vIlsO5dsfckBkXUoT /wk7BrzSgfX+/TVBuwHh71tA4d9vDG4jEMuT4huFmZ8VIYcPknci/bkruoAmHaAGmhk7 cPPiK3TOZDS7ps62tup7dswG7lTpnr1ALtyAixJkpzK/JXfgSm4PFNYn+A7oekkvzmDn 6+aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774851383; x=1775456183; h=content-transfer-encoding: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=zv/cdNKG/SLoH2OSXmBnp/b8qcwYWkoxiHOGhZKCyKU=; b=SLkx9ZIWAfybqfDE8gsfDnj1ard27k4wLPSFo7fWRNeoxbAXukkzWBoZyKXihNBDPU NWhrmKo/WIvK1VflXaAMEcTyTojEPIqvrGiJUGMLAdU6crfZ31iEHgHZ+TMnq0K7w7Be hXnbdhF/t8cs+3sbr15jjtZn0ef/enbW+H3D9ElPuXjEFkulFTJoSbtHNPbROvYjYaSx veBB6dC1xI9dknTBBb276b7xFpTmlq9+KErTiPQa/YFrYJzunXIo9xJfB6XNzLBd46gU ZQy0RCAuyFtakhPSU3ApLKp0Z/2Gb1EmPjXmmDSalZfXx7nVQJNjF004/MQLgTIv6evA 2aeQ== X-Gm-Message-State: AOJu0YzO78GlXFN0lxpOjjE7xmwYGae+EDpjeWMlsKKU6qIBYBC0FNAe EDxQPRtVHYhHnXejjuTbHM0oC4RAe1f8+Ib2VuusXnCWUmyMLnS9zMaavo6zfevztRcdR9llcAY ACEZuF+9T9YoMkE1LK+dq+ELKHWZwGg== X-Gm-Gg: ATEYQzy73h/UHVzcrhlxI9Dl6+GkCzXF1DB/K10nHoUM0hcttTmqill1KdTLgTLd3JB 5Til6htotoeCNiv5++Bp13V+5YAmMzMjsVdSYKF4wLt/DdYXb2mt6uQ62/I08P+jVnLpuq7+SS5 trBa3YBGsaj4QbkYxS7VFkW5naHL2ketWSSBJF7wJEm9bXeLBAQP+hyMnvtUquaBuL3Wry8wGrT q0WpfrIO4fr0dbDVNTfrEH6WEHykGbM3ssuUHwuLjEbcRnuuigy9pOzKQJFYU4WOff+pMUoa9Jl fRstaSehOGrAGg== X-Received: by 2002:a05:651c:f06:b0:38b:e048:57c with SMTP id 38308e7fff4ca-38c731b9dc7mr33928511fa.7.1774851382365; Sun, 29 Mar 2026 23:16:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Mon, 30 Mar 2026 11:46:10 +0530 X-Gm-Features: AQROBzAfgECG6_5pQXlZP8OqhEop2k0hyUMmv5mUf3eF7LFII6rZzepdLnqCkGQ Message-ID: Subject: Re: Bug: wrong relname in RemoveSubscriptionRel() error detail To: Chao Li Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 27, 2026 at 3:22=E2=80=AFPM Chao Li wr= ote: > > Hi, > > I just noticed a wrong relation name in the error detail emitted by Remov= eSubscriptionRel(): > ``` > * > * Drop subscription relation mapping. These can be for a particular > * subscription, or for a particular relation, or both. > */ > void > RemoveSubscriptionRel(Oid subid, Oid relid) > { > Relation rel; > TableScanDesc scan; > ScanKeyData skey[2]; > HeapTuple tup; > int nkeys =3D 0; > > rel =3D table_open(SubscriptionRelRelationId, RowExclusiveLock); > > if (OidIsValid(subid)) > { > ScanKeyInit(&skey[nkeys++], > Anum_pg_subscription_rel_srsubid, > BTEqualStrategyNumber, > F_OIDEQ, > ObjectIdGetDatum(subid)); > } > > if (OidIsValid(relid)) > { > ScanKeyInit(&skey[nkeys++], > Anum_pg_subscription_rel_srrelid, > BTEqualStrategyNumber, > F_OIDEQ, > ObjectIdGetDatum(relid)); > } > > /* Do the search and delete what we found. */ > scan =3D table_beginscan_catalog(rel, nkeys, skey); > while (HeapTupleIsValid(tup =3D heap_getnext(scan, ForwardScanDir= ection))) > { > Form_pg_subscription_rel subrel; > > subrel =3D (Form_pg_subscription_rel) GETSTRUCT(tup); > > if (!OidIsValid(subid) && > subrel->srsubstate !=3D SUBREL_STATE_READY && > get_rel_relkind(subrel->srrelid) !=3D RELKIND_SEQ= UENCE) > { > ereport(ERROR, > (errcode(ERRCODE_INVALID_PARAMETE= R_VALUE), > errmsg("could not drop relation = mapping for subscription \"%s\"", > get_subscription_= name(subrel->srsubid, false)), > errdetail("Table synchronization= for relation \"%s\" is in progress and is in state \"%c\".", > get_rel_name(r= elid), subrel->srsubstate), // <=3D=3D=3D=3D=3D=3D bug is here > > ``` > > In the error detail, it uses relid to get the relation name. But at that = point we are iterating over subrel, and the function argument relid can be = InvalidOid. So the error detail should use subrel->srrelid instead. > > This looks like a first-day bug introducing by ce0fdbf, so I think it=E2= =80=99s worth back-patching. > I tried reproducing the said bug on HEAD, but it doesn=E2=80=99t seem to ex= ist in the current code. To hit the mentioned error, the subid has to be invalid - if (!OidIsValid(subid) && <=3D=3D And currently, the only path that uses an invalid subid is via heap_drop_with_catalog() : =E2=80=A6 /* * Remove any associated relation synchronization states. */ RemoveSubscriptionRel(InvalidOid, relid); =E2=80=A6 But here relid is always a valid OID (it's the table being dropped). The corresponding pg_class row is deleted after RemoveSubscriptionRel(), i.e. via a later call to DeleteRelationTuple(relid); It can only happen with a hypothetical future caller of RemoveSubscriptionRel(InvalidOid, InvalidOid). And in that case, using "subrel->srrelid" would be correct. So this doesn=E2=80=99t appear to be a real issue in the current code, and doesn=E2=80=99t look like a bug to fix now. IMO, if such a caller is added = in the future, we can add a guard at that point. -- Thanks, Nisha