Re: Fix race condition in pg_get_publication_tables with concurrent DROP TABLE

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Ajin Cherian <itsajin(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix race condition in pg_get_publication_tables with concurrent DROP TABLE
Date: 2026-05-04 02:34:00
Message-ID: CALj2ACVv3NNVtqytJR=b4MwPmBm9AckRexGo7r0oVLqWe69NKg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Apr 29, 2026 at 12:15 AM Bharath Rupireddy
<bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>
> Fixed. Please find the attached v5 patch.
>
> The fix is needed only for PG16 and later, not PG15 or PG14. The bug
> was introduced by b7ae03953690 [1] in PG16, which added a table_open()
> call in pg_get_publication_tables(). PG15 and earlier only use
> get_rel_namespace() and syscache lookups, both of which gracefully
> handle dropped relations (returning InvalidOid/false rather than
> erroring).
>
> I verified the bug and the fix on all affected branches. Please find
> the attached version-specific patches for backpatching. Thank you!
>
> [1] b7ae03953690 - Ignore dropped and generated columns from the column list

Please find the attached v6 patch, which fixes a test failure on
FreeBSD. This variant of the build forces parallel query via
debug_parallel_query=regress, causing the pg_get_publication_tables
injection point to fire in parallel workers as well. I disabled forced
parallel query for this test case.

Thank you!

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v6-0001-Fix-pg_get_publication_tables-race-with-concurren.patch application/x-patch 8.3 KB
v6-0001-PG18-Fix-pg_get_publication_tables-race-with-conc.patch application/x-patch 8.3 KB
v6-0001-PG17-Fix-pg_get_publication_tables-race-with-conc.patch application/x-patch 8.5 KB
v6-0001-PG16-Fix-pg_get_publication_tables-race-with-conc.patch application/x-patch 4.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-05-04 04:38:38 Re: Make printtup a bit faster
Previous Message Chao Li 2026-05-04 02:23:47 Adjust pg_stat_get_lock() prorows to match lock types