diff options
author | Amit Kapila | 2023-10-26 01:24:16 +0000 |
---|---|---|
committer | Amit Kapila | 2023-10-26 01:36:55 +0000 |
commit | 29d0a77fa6606f9c01ba17311fc452dabd3f793d (patch) | |
tree | c1d63845bf43db3ab71cb16a43ee53867b6119dc /doc/src | |
parent | bddc2f7480374023218427a0185145a127207c28 (diff) |
Migrate logical slots to the new node during an upgrade.
While reading information from the old cluster, a list of logical
slots is fetched. At the later part of upgrading, pg_upgrade revisits the
list and restores slots by executing pg_create_logical_replication_slot()
on the new cluster. Migration of logical replication slots is only
supported when the old cluster is version 17.0 or later.
If the old node has invalid slots or slots with unconsumed WAL records,
the pg_upgrade fails. These checks are needed to prevent data loss.
The significant advantage of this commit is that it makes it easy to
continue logical replication even after upgrading the publisher node.
Previously, pg_upgrade allowed copying publications to a new node. With
this patch, adjusting the connection string to the new publisher will
cause the apply worker on the subscriber to connect to the new publisher
automatically. This enables seamless continuation of logical replication,
even after an upgrade.
Author: Hayato Kuroda, Hou Zhijie
Reviewed-by: Peter Smith, Bharath Rupireddy, Dilip Kumar, Vignesh C, Shlok Kyal
Discussion: http://postgr.es/m/TYAPR01MB58664C81887B3AF2EB6B16E3F5939@TYAPR01MB5866.jpnprd01.prod.outlook.com
Discussion: http://postgr.es/m/CAA4eK1+t7xYcfa0rEQw839=b2MzsfvYDPz3xbD+ZqOdP3zpKYg@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/pgupgrade.sgml | 78 |
1 files changed, 76 insertions, 2 deletions
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml index 608193b3070..46e8a0b7467 100644 --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -384,6 +384,79 @@ make prefix=/usr/local/pgsql.new install </step> <step> + <title>Prepare for publisher upgrades</title> + + <para> + <application>pg_upgrade</application> attempts to migrate logical + slots. This helps avoid the need for manually defining the same + logical slots on the new publisher. Migration of logical slots is + only supported when the old cluster is version 17.0 or later. + Logical slots on clusters before version 17.0 will silently be + ignored. + </para> + + <para> + Before you start upgrading the publisher cluster, ensure that the + subscription is temporarily disabled, by executing + <link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION ... DISABLE</command></link>. + Re-enable the subscription after the upgrade. + </para> + + <para> + There are some prerequisites for <application>pg_upgrade</application> to + be able to upgrade the logical slots. If these are not met an error + will be reported. + </para> + + <itemizedlist> + <listitem> + <para> + The new cluster must have + <link linkend="guc-wal-level"><varname>wal_level</varname></link> as + <literal>logical</literal>. + </para> + </listitem> + <listitem> + <para> + The new cluster must have + <link linkend="guc-max-replication-slots"><varname>max_replication_slots</varname></link> + configured to a value greater than or equal to the number of slots + present in the old cluster. + </para> + </listitem> + <listitem> + <para> + The output plugins referenced by the slots on the old cluster must be + installed in the new PostgreSQL executable directory. + </para> + </listitem> + <listitem> + <para> + The old cluster has replicated all the transactions and logical decoding + messages to subscribers. + </para> + </listitem> + <listitem> + <para> + All slots on the old cluster must be usable, i.e., there are no slots + whose + <link linkend="view-pg-replication-slots">pg_replication_slots</link>.<structfield>conflicting</structfield> + is <literal>true</literal>. + </para> + </listitem> + <listitem> + <para> + The new cluster must not have permanent logical slots, i.e., + there must be no slots where + <link linkend="view-pg-replication-slots">pg_replication_slots</link>.<structfield>temporary</structfield> + is <literal>false</literal>. + </para> + </listitem> + </itemizedlist> + + </step> + + <step> <title>Stop both servers</title> <para> @@ -650,8 +723,9 @@ rsync --archive --delete --hard-links --size-only --no-inc-recursive /vol1/pg_tb Configure the servers for log shipping. (You do not need to run <function>pg_backup_start()</function> and <function>pg_backup_stop()</function> or take a file system backup as the standbys are still synchronized - with the primary.) Replication slots are not copied and must - be recreated. + with the primary.) Only logical slots on the primary are copied to the + new standby, but other slots on the old standby are not copied so must + be recreated manually. </para> </step> |