pgsql: Migrate logical slots to the new node during an upgrade.
pgsql: Migrate logical slots to the new node during an upgrade.
От:
Amit Kapila <akapila@postgresql.org>
Дата:
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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/29d0a77fa6606f9c01ba17311fc452dabd3f793d Modified Files -------------- doc/src/sgml/ref/pgupgrade.sgml | 78 ++++++++- src/backend/replication/logical/decode.c | 48 +++++- src/backend/replication/logical/logical.c | 75 ++++++++ src/backend/replication/slot.c | 14 ++ src/backend/utils/adt/pg_upgrade_support.c | 44 +++++ src/bin/pg_upgrade/Makefile | 3 + src/bin/pg_upgrade/check.c | 168 +++++++++++++++++- src/bin/pg_upgrade/function.c | 30 +++- src/bin/pg_upgrade/info.c | 166 +++++++++++++++++- src/bin/pg_upgrade/meson.build | 1 + src/bin/pg_upgrade/pg_upgrade.c | 74 +++++++- src/bin/pg_upgrade/pg_upgrade.h | 22 ++- src/bin/pg_upgrade/server.c | 25 ++- .../t/003_upgrade_logical_replication_slots.pl | 192 +++++++++++++++++++++ src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_proc.dat | 5 + src/include/replication/logical.h | 5 + src/tools/pgindent/typedefs.list | 2 + 18 files changed, 927 insertions(+), 27 deletions(-)
Re: pgsql: Migrate logical slots to the new node during an upgrade.
От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 26.10.23 04:14, Amit Kapila wrote: > Migrate logical slots to the new node during an upgrade. Something in this patch is causing the pg_upgrade test to be run in the source directory and leaving files such as delete_old_cluster.sh around there. (This is under meson; there shouldn't be any new files appearing in the source directory during the build.) Check please.
Re: pgsql: Migrate logical slots to the new node during an upgrade.
От:
Andrew Dunstan <andrew@dunslane.net>
Дата:
On 2023-11-06 Mo 05:31, Peter Eisentraut wrote:
> On 26.10.23 04:14, Amit Kapila wrote:
>> Migrate logical slots to the new node during an upgrade.
>
> Something in this patch is causing the pg_upgrade test to be run in
> the source directory and leaving files such as delete_old_cluster.sh
> around there. (This is under meson; there shouldn't be any new files
> appearing in the source directory during the build.) Check please.
>
>
>
The same probably applies to VPATH builds using Makefiles.
002_pg_upgrade.pl has this, which I think should cure the new script:
# In a VPATH build, we'll be started in the source directory, but we want
# to run pg_upgrade in the build directory so that any files generated
finish
# in it, like delete_old_cluster.{sh,bat}.
chdir ${PostgreSQL::Test::Utils::tmp_check};
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Re: pgsql: Migrate logical slots to the new node during an upgrade.
От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Mon, Nov 6, 2023 at 4:01 PM Peter Eisentraut wrote: > > On 26.10.23 04:14, Amit Kapila wrote: > > Migrate logical slots to the new node during an upgrade. > > Something in this patch is causing the pg_upgrade test to be run in the > source directory and leaving files such as delete_old_cluster.sh around > there. (This is under meson; there shouldn't be any new files appearing > in the source directory during the build.) Check please. > Noted. I'll take care of this. -- With Regards, Amit Kapila.