agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Validate ALTER PUBLICATION after acquiring the publication lock.
Date: Fri, 11 Sep 2026 04:27:30 +0000
Message-ID: <E1x4srJ-00000004O2L-2xHB@gemulon.postgresql.org> (raw)

Validate ALTER PUBLICATION after acquiring the publication lock.

AlterPublicationOptions() can use stale publication state when the
publication is modified concurrently while waiting for the publication
lock. In particular, a concurrent ALTER PUBLICATION ... SET ALL TABLES
can change puballtables, causing the validation to make decisions based
on the old value and leads to assertion failure. Likewise,
CheckAlterPublication() could miss a table added concurrently, letting
SET ALL TABLES EXCEPT (...) leave pg_publication_rel with a mixture of
inclusion and exclusion rows.

Fix by acquiring the lock and re-reading the publication tuple in
AlterPublication() before either path runs, and by calling
CheckAlterPublication() only after that.

Also fix 037_except.pl, which left one computed result untested and
silently reused a subscription created by an earlier test.

Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/CALDaNm1r2MkGu6h8zgU1Kj1sX-FcMQ7wGTeLSnhx-5joiyXEvg@mail.gmail.com
Backpatch-through: 19, where it was introduced

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f6b2d6b827a0f1a7485ca43a64b9ddfbebcd2934

Modified Files
--------------
src/backend/commands/publicationcmds.c | 73 ++++++++++++++++++----------------
src/test/subscription/t/037_except.pl  | 21 +++++-----
2 files changed, 51 insertions(+), 43 deletions(-)



view thread (2+ messages)

Message-ID: <E1x4srJ-00000004O2L-2xHB@gemulon.postgresql.org>
Permalink:  ../E1x4srJ-00000004O2L-2xHB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x4srJ-00000004O2L-2xHB@gemulon.postgresql.org

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Validate ALTER PUBLICATION after acquiring the publication lock.
  In-Reply-To: <E1x4srJ-00000004O2L-2xHB@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox