| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | vignesh C <vignesh21(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Review items for EXCEPT TABLE publication |
| Date: | 2026-09-10 07:17:17 |
| Message-ID: | 3B3DA418-8D27-44D9-AEA6-8CC24EB33CEB@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Sep 10, 2026, at 13:39, vignesh C <vignesh21(at)gmail(dot)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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-09-10 07:18:49 | Re: SSI: ON CONFLICT DO SELECT takes no predicate lock on the returned row |
| Previous Message | Fujii Masao | 2026-09-10 07:13:44 | Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable |