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.98.2) (envelope-from ) id 1xR5j1-00000000fn9-3C1G for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 10:38:43 +0000 Received: from localhost ([127.0.0.1]:44518 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR5iz-0000000AE0t-1Ph6 for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 10:38:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:34534) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR0xI-00000008q8h-2GHG for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:33:08 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR0xG-00000000PDV-39qQ for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:33:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=VyqA/B6pUVJvQyyU36HqLPn770NEA7bwqonGaYih93A=; b=YSHGvBoyyl/DOMjVVVxxWd/ZrE D8ePRp5mYWk4SsDYKwpJDM4pN6vIzNZoAoaoRg05z6fo+Eu9KLqw28O24Ho9kxNWx2o2nxvopcX8G iH6TRkJjkQQDNjbxXC7nUWgt2yjv/idVx4H7Xptx+JwkWjjlnkaa1Vjq3OvdE8HiCey2oBwVCcyWV VdVD0q6qWun4aBBqWMWxhMnppvLbdBVoFWr9CTy0usxgRzFZ887Fjm12aXn+DNlz+ynITTPXr1oRh z6rJz8NtYECMPsgzBSJQT2HHR3vY1utZYRpdwsott8nheoAp7LM7HfodEKuU6BgGp1Z3zQI4yhvsF DnWNQPsQ==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR0xE-00000000squ-3FnE for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:33:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR0xD-00000002IDO-2hQw for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:33:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19864: pg_get_publication_tables() gets cache lookup error after concurrent DROP PUBLICATION To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: imchifan8@gmail.com Reply-To: imchifan8@gmail.com, pgsql-bugs@lists.postgresql.org Date: Wed, 11 Nov 2026 05:33:01 +0000 Message-ID: <19864-5260a1fbeec7728c@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19864 Logged by: Noah Email address: imchifan8@gmail.com PostgreSQL version: 18.6 Operating system: Linux/amd64 Description: =20 pg_get_publication_tables() raises an internal cache lookup error when it blocks while opening a published table and another session drops and commits the publication before the function resumes. A multi-call catalog SRF should safely handle retained object identifiers after concurrent removal, either by omitting stale rows or otherwise completing without an internal cache lookup failure. How to repeat: The dblink extension must be available. Run the following as one script in a fresh database using psql: DROP PUBLICATION IF EXISTS race_pub; DROP SCHEMA IF EXISTS race_schema CASCADE; CREATE EXTENSION dblink; CREATE SCHEMA race_schema; CREATE TABLE race_schema.race_table (id integer); CREATE PUBLICATION race_pub FOR TABLES IN SCHEMA race_schema; BEGIN; LOCK TABLE race_schema.race_table IN ACCESS EXCLUSIVE MODE; SELECT dblink_connect( 'race_conn', 'dbname=3D' || current_database()); SELECT dblink_send_query( 'race_conn', $$SELECT relid::regclass::text FROM pg_get_publication_tables('race_pub') ORDER BY 1$$); SELECT pg_sleep(1); SELECT EXISTS ( SELECT 1 FROM pg_locks WHERE relation =3D 'race_schema.race_table'::regclass AND mode =3D 'AccessShareLock' AND NOT granted ) AS remote_enumerator_waiting_on_table; DROP PUBLICATION race_pub; COMMIT; SELECT * FROM dblink_get_result('race_conn') AS result(published_table text); SELECT dblink_disconnect('race_conn'); The lock check returned true, confirming that the remote call was waiting to open the table. After DROP PUBLICATION committed, dblink_get_result() reported: ERROR: cache lookup failed for publication 17010 CONTEXT: while executing query on dblink connection named "race_conn" The affected statement failed, but PostgreSQL remained healthy. Retrying after the concurrent catalog DDL has finished allows the introspection operation to proceed. The runtime failure was reproduced on PostgreSQL 18.6 on Linux/amd64. Separately, inspection of PostgreSQL 20devel source found the same relevant path: pg_get_publication_tables() retains publication OIDs across SRF calls and later passes each retained OID to GetPublication(). Its concurrent-drop handling tolerates a missing relation through try_table_open(), but not a publication that has disappeared. This occurs when publication tables are enumerated while concurrent publication DDL removes the publication.