| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | Dilip Kumar <dilipbalaut(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-16 03:54:10 |
| Message-ID: | CAJpy0uD+c=z9ezoeCmrMAL5BGtdrUFBX5VOJD6qhBeZyaRR2DA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Sat, Nov 14, 2026 at 4:18 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> 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?
Agreed; the current result is wrong. It seems a regerssion of 0003;
is_table_publishable_in_publication() was evaluated with the
publication’s current 'publish_via_partition_root', while the list of
relations was built on the first call with the old setting. So
tbl_part2 looked “not published” even though only its representation
changed. Since tbl_part1 has already been returned, we can’t produce
the after-state (tbl_parent) without materializing the result, so I
think the right answer is the before-state (tbl_part1, tbl_part2),
which is also what HEAD returns. Thoughts?
The way to achieve this is to let
is_table_publishable_in_publication() decide based on the publication
collected on the first call (saved in publication_tables_state). Its
membership lookups (pg_publication_rel, pg_publication_namespace,
ancestors etc) still read the current catalog, so a table that was
really removed from the publication is still skipped, as 0003 intends;
only the change of pub-setting is no longer confused as a removal of
table.
Do you think 0003, along with the fix suggested above to address its
regerssion, should be handled as a separate bug? That would keep the
drop-pub and alter-pub fixes, and their analysis, separate.
thanks
Shveta
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shveta malik | 2026-11-16 04:55:48 | Re: BUG #19864: pg_get_publication_tables() gets cache lookup error after concurrent DROP PUBLICATION |
| Previous Message | PG Bug reporting form | 2026-11-15 18:38:20 | BUG #19906: Backend crash (signal 11) creating a LANGUAGE sql function that returns a composite type from a sub- |