8000 Doc: Improve logical replication failover documentation. · postgres/postgres@24f6086 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24f6086

Browse files
author
Amit Kapila
committed
Doc: Improve logical replication failover documentation.
Clarified that the failover steps apply to a specific PostgreSQL subscriber and added guidance for verifying replication slot synchronization during planned failover. Additionally, corrected the standby query to avoid false positives by checking invalidation_reason IS NULL instead of conflicting. Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Author: Shveta Malik <shveta.malik@gmail.com> Backpatch-through: 17, where it was introduced Discussion: https://www.postgresql.org/message-id/CAExHW5uiZ-fF159=jwBwPMbjZeZDtmcTbN+hd4mrURLCg2uzJg@mail.gmail.com
1 parent fef6da9 commit 24f6086

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

doc/src/sgml/logical-replication.sgml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,8 @@ HINT: To initiate replication, you must manually create the replication slot, e
709709
</para>
710710

711711
<para>
712-
To confirm that the standby server is indeed ready for failover, follow these
713-
steps to verify that all necessary logical replication slots have been
712+
To confirm that the standby server is indeed ready for failover for a given subscriber, follow these
713+
steps to verify that all the logical replication slots required by that subscriber have been
714714
synchronized to the standby server:
715715
</para>
716716

@@ -764,7 +764,7 @@ HINT: To initiate replication, you must manually create the replication slot, e
764764
Check that the logical replication slots identified above exist on
765765
the standby server and are ready for failover.
766766
<programlisting>
767-
/* standby # */ SELECT slot_name, (synced AND NOT temporary AND NOT conflicting) AS failover_ready
767+
/* standby # */ SELECT slot_name, (synced AND NOT temporary AND invalidation_reason IS NULL) AS failover_ready
768768
FROM pg_replication_slots
769769
WHERE slot_name IN
770770
('sub1','sub2','sub3', 'pg_16394_sync_16385_7394666715149055164');
@@ -782,10 +782,42 @@ HINT: To initiate replication, you must manually create the replication slot, e
782782
<para>
783783
If all the slots are present on the standby server and the result
784784
(<literal>failover_ready</literal>) of the above SQL query is true, then
785-
existing subscriptions can continue subscribing to publications now on the
786-
new primary server.
785+
existing subscriptions can continue subscribing to publications on the new
786+
primary server.
787+
</para>
788+
789+
<para>
790+
The first two steps in the above procedure are meant for a
791+
<productname>PostgreSQL</productname> subscriber. It is recommended to run
792+
these steps on each subscriber node, that will be served by the designated
793+
standby after failover, to obtain the complete list of replication
794+
slots. This list can then be verified in Step 3 to ensure failover readiness.
795+
Non-<productname>PostgreSQL</productname> subscribers, on the other hand, may
796+
use their own methods to identify the replication slots used by their
797+
respective subscriptions.
798+
</para>
799+
800+
<para>
801+
In some cases, such as during a planned failover, it is necessary to confirm
802+
that all subscribers, whether <productname>PostgreSQL</productname> or
803+
non-<productname>PostgreSQL</productname>, will be able to continue
804+
replication after failover to a given standby server. In such cases, use the
805+
following SQL, instead of performing the first two steps above, to identify
806+
which replication slots on the primary need to be synced to the standby that
807+
is intended for promotion. This query returns the relevant replication slots
808+
associated with all the failover-enabled subscriptions.
787809
</para>
788810

811+
<para>
812+
<programlisting>
813+
/* primary # */ SELECT array_agg(quote_literal(r.slot_name)) AS slots
814+
FROM pg_replication_slots r
815+
WHERE r.failover AND NOT r.temporary;
816+
slots
817+
-------
818+
{'sub1','sub2','sub3', 'pg_16394_sync_16385_7394666715149055164'}
819+
(1 row)
820+
</programlisting></para>
789821
</sect1>
790822

791823
<sect1 id="logical-replication-row-filter">

0 commit comments

Comments
 (0)
0