From: Chao Li <li.evan.chao@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Review items for EXCEPT TABLE publication
Date: Thu, 10 Sep 2026 15:17:17 +0800
Message-ID: <3B3DA418-8D27-44D9-AEA6-8CC24EB33CEB@gmail.com> (raw)
In-Reply-To: <CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com>
References: <CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com>
> On Sep 10, 2026, at 13:39, vignesh C <vignesh21@gmail.com> wrote:
>
> Finding #2: ALTER PUBLICATION validates against pre-lock state
>
> CheckAlterPublication() validates that pg_publication_rel entries are
> either all inclusions or all exclusions. However, this check is
> performed before LockDatabaseObject(). A concurrent ALTER PUBLICATION
> can therefore add an inclusion while another session is validating and
> waiting for the lock. The second command then proceeds without
> revalidating after the lock is acquired, leaving the publication with
> a mixture of inclusion and exclusion entries.
>
> Test to reproduce:
> -- session 1: -- session 2:
> CREATE PUBLICATION p;
> BEGIN;
> ALTER PUBLICATION p
> ADD TABLE t2;
> ALTER PUBLICATION p
> SET ALL TABLES EXCEPT (TABLE t1);
> -- passes CheckAlterPublication()
> -- while s1's row is invisible,
> -- then blocks on the lock
> COMMIT; -- resumes without re-checking
>
> The fix is to perform CheckAlterPublication() after acquiring the
> publication lock, so that validation is performed against the current
> publication state.
>
>
> Regards,
> Vignesh
> <v1-0001-Fix-ALTER-PUBLICATION-race-with-concurrent-SET-AL.patch><v1-0005-Prevent-unlogged-tables-in-publication-EXCEPT-cla.patch><v1-0003-Fix-missing-check-in-test_except_root_partition.patch><v1-0002-Fix-ALTER-PUBLICATION-validation-race.patch><v1-0004-Fix-test-to-use-a-fresh-subscription.patch>
v1-0002 looks correct and appears to fix the race described in finding 2.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: li.evan.chao@gmail.com, vignesh21@gmail.com
Subject: Re: Review items for EXCEPT TABLE publication
In-Reply-To: <3B3DA418-8D27-44D9-AEA6-8CC24EB33CEB@gmail.com>
References: <CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com> <3B3DA418-8D27-44D9-AEA6-8CC24EB33CEB@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox