Re: BUG #19864: pg_get_publication_tables() gets cache lookup error after concurrent DROP PUBLICATION

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Ajin Cherian <itsajin(at)gmail(dot)com>, imchifan8(at)gmail(dot)com, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: BUG #19864: pg_get_publication_tables() gets cache lookup error after concurrent DROP PUBLICATION
Date: 2026-11-14 10:48:29
Message-ID: CAFiTN-u+J2sy+hY9d71ivBcy09kDeX9_gQj_BPLPrcNi9cG-tw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Nov 13, 2026 at 3:40 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> On Fri, Nov 13, 2026 at 3:01 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
> >
> > Hello
> >
> > There's still another remaining issue with the above patches, pointed
> > out by claude: a missing pg_publication_rel entry while the
> > publication still exists isn't always the partition-via-parent case,
> > the table could also have been removed from the publication
> > concurrently.
>
> Okay, thanks for reporting. I agree with the problem. It seems like
> another variation of commit 63e7a0d2c3 (due to DROP TABLE part), but
> it's also related to current thread because the publication is
> concurrently 'altered' (similar to original concurrent 'drop
> publication'). Therefore, I'm okay with incorporating the fix into the
> current patch. I have attached the fix as 003.
>
> v4-0001 is same as Ajin's v3-0001.
> v4-0002 fixes the wrong column list and filter for the last fetched
> table in a concurrently dropped publication.
> v4-0003 fixes the wrong column list and row filter for concurrently
> altered publication that drops a table.

Thanks for the patch, Shveta. While testing, I see all the reported
cases are fixed but found another issue, check below test

-- Setup
CREATE TABLE tbl_parent (a int) PARTITION BY RANGE (a);
CREATE TABLE tbl_part1 PARTITION OF tbl_parent FOR VALUES FROM (1) TO (10);
CREATE TABLE tbl_part2 PARTITION OF tbl_parent FOR VALUES FROM (10) TO (20);
CREATE PUBLICATION pub FOR TABLE tbl_parent WITH
(publish_via_partition_root = false);

Session 1:
BEGIN;
LOCK TABLE tbl_part2 IN ACCESS EXCLUSIVE MODE;

Session 2:
SELECT relid::regclass FROM pg_get_publication_tables('pub');
-- Emits tbl_part1, then blocks waiting on tbl_part2

Session 1:
ALTER PUBLICATION pub SET (publish_via_partition_root = true);
COMMIT;

Session 2:
relid
-----------
tbl_part1
(1 row)

So while it was waiting on the lock on tbl_part2, we concurrently
updated publish_via_partition_root to true, and due to that the
inidividual partitions are not listed and it skipped tbl_part2,
whereas tbl_part1 is already listed, that was never valid either
before (tbl_part1, tbl_part2) or after (tbl_parent) the ALTER
PUBLICATION, what do you think?

--
Regards,
Dilip Kumar
Google

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-11-14 10:50:33 Re: BUG #19837: ORDER BY/DISTINCT ON use wrong column with grouping set duplicates
Previous Message Masahiko Sawada 2026-11-14 01:44:27 Re: BUG #19884: pg_publication_tables omits a detach-pending partition in root mode