pgsql: Fix ALTER SUBSCRIPTION ... SET PUBLICATION ... command.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix ALTER SUBSCRIPTION ... SET PUBLICATION ... command.
Date: 2025-03-14 03:46:31
Message-ID: E1tsw0F-002NUB-2s@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix ALTER SUBSCRIPTION ... SET PUBLICATION ... command.

The problem is that ALTER SUBSCRIPTION ... SET PUBLICATION ... will lead
to restarting of apply worker and after the restart, the apply worker will
use the existing slot and replication origin corresponding to the
subscription. Now, it is possible that before the restart, the origin has
not been updated, and the WAL start location points to a location before
where PUBLICATION pointed to by SET PUBLICATION doesn't exist, and that
can lead to an error like: "ERROR: publication "pub1" does not exist".
Once this error occurs, apply worker will never be able to proceed and
will always return the same error.

We decided to skip loading the publication if the publication does not
exist. The publication is loaded later and updates the relation entry when
the publication gets created.

We decided not to backpatch this as this is a behaviour change, and we don't
see field reports. This problem has been found by intermittent buildfarm
failures.

Author: vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Discussion: https://postgr.es/m/flat/CALDaNm0-n8FGAorM%2BbTxkzn%2BAOUyx5%3DL_XmnvOP6T24%2B-NcBKg%40mail.gmail.com
Discussion: https://postgr.es/m/CAA4eK1+T-ETXeRM4DHWzGxBpKafLCp__5bPA_QZfFQp7-0wj4Q@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7c99dc587a010a0c40d72a0e435111ca7a371c02

Modified Files
--------------
src/backend/replication/pgoutput/pgoutput.c | 16 +++++++++--
src/test/subscription/t/024_add_drop_pub.pl | 44 ++++++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2025-03-14 04:16:46 pgsql: Improve buffer manager API for backend pin limits.
Previous Message Tom Lane 2025-03-13 20:08:09 pgsql: Fix ARRAY_SUBLINK and ARRAY[] for int2vector and oidvector input