> On Sep 10, 2026, at 13:39, vignesh C <[email protected]> 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/