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 <[email protected]> Reviewed-by: Amit Kapila <[email protected]> Reviewed-by: Chao Li <[email protected]> Reviewed-by: shveta malik <[email protected]> Reviewed-by: Hayato Kuroda <[email protected]> Discussion: https://postgr.es/m/caldanm1r2mkgu6h8zgu1kj1sx-fcmq7wgtelsnhx-5joiyx...@mail.gmail.com Backpatch-through: 19, where it was introduced Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/5624de9904ca560c0d4473cb9e86108f4b69be38 Modified Files -------------- src/backend/commands/publicationcmds.c | 73 ++++++++++++++++++---------------- src/test/subscription/t/037_except.pl | 21 +++++----- 2 files changed, 51 insertions(+), 43 deletions(-)
