Oh sorry, I missed the part of you upgrading the subscriber as well. I'll need to check that too, will get back on this tomorrow (too late now)
On Sun, Feb 6, 2022, 4:11 AM Vijaykumar Jain <vijaykumarjain.github@xxxxxxxxx> wrote:
--On Sun, 6 Feb 2022 at 02:20, Axel Rau <Axel.Rau@xxxxxxxxx> wrote:Am 03.02.22 um 17:06 schrieb Axel Rau:
> Replication to another standby is working, but the slot of the upgraded
> standby is inactive.
Also the subscription has subenabled set to false.
Enabling it, turns on the active bit at the publisher side, but does not
start replication.
Recreating the subscription does not help either.
There should be a solution as logical replication is documented to
support upgrade of the standby.i just performed an upgrade using pg_upgrade link mode from pg13 to pg14.the only additional step as mentioned in the docs was to create the logical replication slot manually.subscription started working just fine.postgres@controller:/var/tmp/log$ pwd/var/tmp/logpostgres@controller:/var/tmp/log$ /usr/lib/postgresql/14/bin/initdb -D /var/tmp/log/testdbpostgres@controller:/var/tmp/log$ tail postgresql.conf >> testdb/postgresql.confpostgres@controller:/var/tmp/log$ tail testdb/postgresql.conf# Add settings for extensions herewal_level=logicalarchive_mode = onarchive_command = '/bin/true'max_wal_size = 48MBmin_wal_size = 32MBshared_buffers = 32MBport = 8001max_logical_replication_workers = 10postgres@controller:/var/tmp/log$ /usr/lib/postgresql/14/bin/pg_ctl -D testdb -l logfile startwaiting for server to start.... doneserver startedpostgres@controller:/var/tmp/log$ psql -p 8001psql (14.1 (Ubuntu 14.1-2.pgdg20.04+1))Type "help" for help.postgres=# create table t(id int primary key);CREATE TABLEpostgres=# create subscription mysub connection 'port=5001' publication mypub;NOTICE: created replication slot "mysub" on publisherCREATE SUBSCRIPTIONpostgres=# table t;id----12(2 rows)-- after i do an upgrade it stop getting updates from publisher as no slot on pg14postgres=# select * from pg_stat_subscription;subid | subname | pid | relid | received_lsn | last_msg_send_time | last_msg_receipt_time | latest_end_lsn | latest_end_time-------+---------+-----+-------+--------------+--------------------+-----------------------+----------------+-----------------16389 | mysub | | | | | | |(1 row)-- but when i create the logical replication slot on pg14 (see below), it starts running just finepostgres=# select * from pg_stat_subscription;postgres=# \xExpanded display is on.postgres=# select * from pg_stat_subscription;-[ RECORD 1 ]---------+---------------------------------subid | 16389subname | mysubpid | 6099relid |received_lsn | 0/C1BC8E0last_msg_send_time | 2022-02-06 03:59:07.272526+05:30last_msg_receipt_time | 2022-02-06 03:59:07.272627+05:30latest_end_lsn | 0/C1BC8E0latest_end_time | 2022-02-06 03:59:07.272526+05:30postgres=# table t;-[ RECORD 1 ]id | 1-[ RECORD 2 ]id | 2-[ RECORD 3 ]id | 3------------------------------------------------------------------------------------------------- upgrade from pg13 to pg14postgres@controller:~/temp/13$ tail postgresql.conf# Add settings for extensions herewal_level=logicalarchive_mode = onarchive_command = '/bin/true'max_wal_size = 48MBmin_wal_size = 32MBshared_buffers = 32MBport = 5001max_logical_replication_workers = 10postgres@controller:~/temp/13$ initdb -D pg13postgres@controller:~/temp/13$ cp postgresql.conf pg13/postgresql.confpostgres@controller:~/temp/13$ pg_ctl -D pg13 -l logfile startwaiting for server to start.... doneserver startedpostgres@controller:~/temp/13$ psql -p 5001psql (13.5 (Ubuntu 13.5-2.pgdg20.04+1))Type "help" for help.postgres=# create table t(id int primary key);CREATE TABLEpostgres=# insert into t values (1);INSERT 0 1postgres=# insert into t values (2);INSERT 0 1postgres=# checkpoint;CHECKPOINTpostgres=# create publication mypub for table t;CREATE PUBLICATIONpostgres=# \xExpanded display is on.postgres=# select * from pg_replication_slots; -- note the details as we need to create on pg14 after upgrade-[ RECORD 1 ]-------+----------slot_name | mysubplugin | pgoutputslot_type | logicaldatoid | 13414database | postgrestemporary | factive | tactive_pid | 5332xmin |catalog_xmin | 489restart_lsn | 0/15E7098confirmed_flush_lsn | 0/15E70D0wal_status | reservedsafe_wal_size |postgres=# \qpostgres@controller:~/temp/13$ pg_ctl -D pg13 -l logfile stopwaiting for server to shut down.... doneserver stopped---------------------------------------pg14postgres@controller:~/temp/14$ initdb -D /var/lib/postgresql/temp/14/pg14#perform upgradepostgres@controller:~/temp/14$ /usr/lib/postgresql/${NEW_PSQL}/bin/pg_upgrade -b /usr/lib/postgresql/${OLD_PSQL}/bin/ -B /usr/lib/postgresql/${NEW_PSQL}/bin/ -d /var/lib/postgresql/temp/${OLD_PSQL}/pg${OLD_PSQL} -D /var/lib/postgresql/temp//${NEW_PSQL}/pg${NEW_PSQL} -o "-c config-file=/var/lib/postgresql/temp/${OLD_PSQL}/pg${OLD_PSQL}/postgresql.conf" -O "-c config-file=/var/lib/postgresql/temp/${NEW_PSQL}/pg${NEW_PSQL}/postgresql.conf" --linkPerforming Consistency Checks-----------------------------Checking cluster versions okChecking database user is the install user okChecking database connection settings okChecking for prepared transactions okChecking for system-defined composite types in user tables okChecking for reg* data types in user tables okChecking for contrib/isn with bigint-passing mismatch okChecking for user-defined encoding conversions okChecking for user-defined postfix operators okCreating dump of global objects okCreating dump of database schemasokChecking for presence of required libraries okChecking database user is the install user okChecking for prepared transactions okChecking for new cluster tablespace directories okIf pg_upgrade fails after this point, you must re-initdb thenew cluster before continuing.Performing Upgrade------------------Analyzing all rows in the new cluster okFreezing all rows in the new cluster okDeleting files from new pg_xact okCopying old pg_xact to new server okSetting oldest XID for new cluster okSetting next transaction ID and epoch for new cluster okDeleting files from new pg_multixact/offsets okCopying old pg_multixact/offsets to new server okDeleting files from new pg_multixact/members okCopying old pg_multixact/members to new server okSetting next multixact ID and offset for new cluster okResetting WAL archives okSetting frozenxid and minmxid counters in new cluster okRestoring global objects in the new cluster okRestoring database schemas in the new clusterokAdding ".old" suffix to old global/pg_control okIf you want to start the old cluster, you will need to removethe ".old" suffix from /var/lib/postgresql/temp/13/pg13/global/pg_control.old.Because "link" mode was used, the old cluster cannot be safelystarted once the new cluster has been started.Linking user relation filesokSetting next OID for new cluster okSync data directory to disk okCreating script to delete old cluster okChecking for extension updates okUpgrade Complete----------------Optimizer statistics are not transferred by pg_upgrade.Once you start the new server, consider running:/usr/lib/postgresql/14/bin/vacuumdb --all --analyze-in-stagesRunning this script will delete the old cluster's data files:./delete_old_cluster.sh#copy the conf filepostgres@controller:~/temp/14$ cp postgresql.conf pg14/postgres@controller:~/temp/14$ pg_ctl -D pg14 -l logfile startwaiting for server to start.... doneserver startedpostgres@controller:~/temp/14$ /usr/lib/postgresql/14/bin/vacuumdb -p 5001 --all --analyze-in-stagesvacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)vacuumdb: processing database "postgres": Generating default (full) optimizer statisticsvacuumdb: processing database "template1": Generating default (full) optimizer statisticspostgres@controller:~/temp/14$ psql -p 5001### this is the only post action after upgrade i had to do (since you would use ansible, you can automate this my creating slots manually or via if exists and not via create subscriptionpsql (14.1 (Ubuntu 14.1-2.pgdg20.04+1))Type "help" for help.postgres=# SELECT * FROM pg_create_logical_replication_slot('mysub', 'pgoutput', false, true);slot_name | lsn-----------+-----------mysub | 0/C19E358(1 row)postgres=# select * from pg_replication_slots;postgres=# \xExpanded display is on.postgres=# select * from pg_replication_slots;-[ RECORD 1 ]-------+----------slot_name | mysubplugin | pgoutputslot_type | logicaldatoid | 16401database | postgrestemporary | factive | tactive_pid | 6100xmin |catalog_xmin | 760restart_lsn | 0/C19E320confirmed_flush_lsn | 0/C19E358wal_status | reservedsafe_wal_size |two_phase | t--- the below changes get pushed to subscriber just fine. i did not create publication.postgres=# insert into t values (3);INSERT 0 1postgres=# \qpostgres@controller:~/temp/14$ pg_ctl -D pg14 -l logfile stopwaiting for server to shut down.... doneserver stoppedThanks,Vijay