pgsql: Allow upgrades to preserve the full subscription's state.

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема pgsql: Allow upgrades to preserve the full subscription's state.
Дата
Msg-id E1rKV7t-00D3qt-Kc@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Allow upgrades to preserve the full subscription's state.  (Peter Eisentraut <peter@eisentraut.org>)
Список pgsql-committers
Allow upgrades to preserve the full subscription's state.

This feature will allow us to replicate the changes on subscriber nodes
after the upgrade.

Previously, only the subscription metadata information was preserved.
Without the list of relations and their state, it's not possible to
re-enable the subscriptions without missing some records as the list of
relations can only be refreshed after enabling the subscription (and
therefore starting the apply worker).  Even if we added a way to refresh
the subscription while enabling a publication, we still wouldn't know
which relations are new on the publication side, and therefore should be
fully synced, and which shouldn't.

To preserve the subscription relations, this patch teaches pg_dump to
restore the content of pg_subscription_rel from the old cluster by using
binary_upgrade_add_sub_rel_state SQL function. This is supported only
in binary upgrade mode.

The subscription's replication origin is needed to ensure that we don't
replicate anything twice.

To preserve the replication origins, this patch teaches pg_dump to update
the replication origin along with creating a subscription by using
binary_upgrade_replorigin_advance SQL function to restore the
underlying replication origin remote LSN. This is supported only in
binary upgrade mode.

pg_upgrade will check that all the subscription relations are in 'i'
(init) or in 'r' (ready) state and will error out if that's not the case,
logging the reason for the failure. This helps to avoid the risk of any
dangling slot or origin after the upgrade.

Author: Vignesh C, Julien Rouhaud, Shlok Kyal
Reviewed-by: Peter Smith, Masahiko Sawada, Michael Paquier, Amit Kapila, Hayato Kuroda
Discussion: https://postgr.es/m/20230217075433.u5mjly4d5cr4hcfe@jrouhaud

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9a17be1e244a45a77de25ed2ada246fd34e4557d

Modified Files
--------------
doc/src/sgml/ref/pgupgrade.sgml            |  50 +++++
src/backend/catalog/pg_subscription.c      |  16 +-
src/backend/commands/subscriptioncmds.c    |   4 +-
src/backend/utils/adt/pg_upgrade_support.c | 106 ++++++++++
src/bin/pg_dump/common.c                   |  22 ++
src/bin/pg_dump/pg_dump.c                  | 229 ++++++++++++++++++++-
src/bin/pg_dump/pg_dump.h                  |  24 +++
src/bin/pg_dump/pg_dump_sort.c             |  11 +-
src/bin/pg_upgrade/check.c                 | 193 ++++++++++++++++-
src/bin/pg_upgrade/info.c                  |  56 ++++-
src/bin/pg_upgrade/meson.build             |   1 +
src/bin/pg_upgrade/pg_upgrade.h            |   2 +
src/bin/pg_upgrade/t/004_subscription.pl   | 319 +++++++++++++++++++++++++++++
src/include/catalog/catversion.h           |   2 +-
src/include/catalog/pg_proc.dat            |  10 +
src/include/catalog/pg_subscription_rel.h  |   2 +-
src/tools/pgindent/typedefs.list           |   1 +
17 files changed, 1032 insertions(+), 16 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Turn AT_PASS_* macros into an enum
Следующее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Replace the relid in some missing fields during SJE