Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5b8f2cc

Browse files
author
Amit Kapila
committed
Doc: Fix pg_copy_logical_replication_slot description.
This commit documents that the failover option is not copied when using the pg_copy_logical_replication_slot function. In passing, we modify the comments in the function clarifying the reason for this behavior. Reported-by: <duffieldzane@gmail.com> Author: Hou Zhijie <houzj.fnst@fujitsu.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Backpatch-through: 17, where it was introduced Discussion: https://postgr.es/m/173976850802.682632.11315364077431550250@wrigleys.postgresql.org
1 parent 15601fa commit 5b8f2cc

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

doc/src/sgml/func.sgml

+4
Original file line numberDiff line numberDiff line change
@@ -29374,6 +29374,10 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2937429374
from the same <acronym>LSN</acronym> as the source logical slot. Both
2937529375
<parameter>temporary</parameter> and <parameter>plugin</parameter> are
2937629376
optional; if they are omitted, the values of the source slot are used.
29377+
The <literal>failover</literal> option of the source logical slot
29378+
is not copied and is set to <literal>false</literal> by default. This
29379+
is to avoid the risk of being unable to continue logical replication
29380+
after failover to standby where the slot is being synchronized.
2937729381
</para></entry>
2937829382
</row>
2937929383

src/backend/replication/slotfuncs.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,18 @@ copy_replication_slot(FunctionCallInfo fcinfo, bool logical_slot)
695695
* hence pass find_startpoint false. confirmed_flush will be set
696696
* below, by copying from the source slot.
697697
*
698-
* To avoid potential issues with the slot synchronization where the
699-
* restart_lsn of a replication slot can go backward, we set the
700-
* failover option to false here. This situation occurs when a slot
701-
* on the primary server is dropped and immediately replaced with a
702-
* new slot of the same name, created by copying from another existing
703-
* slot. However, the slot synchronization will only observe the
704-
* restart_lsn of the same slot going backward.
698+
* We don't copy the failover option to prevent potential issues with
699+
* slot synchronization. For instance, if a slot was synchronized to
700+
* the standby, then dropped on the primary, and immediately recreated
701+
* by copying from another existing slot with much earlier restart_lsn
702+
* and confirmed_flush_lsn, the slot synchronization would only
703+
* observe the LSN of the same slot moving backward. As slot
704+
* synchronization does not copy the restart_lsn and
705+
* confirmed_flush_lsn backward (see update_local_synced_slot() for
706+
* details), if a failover happens before the primary's slot catches
707+
* up, logical replication cannot continue using the synchronized slot
708+
* on the promoted standby because the slot retains the restart_lsn
709+
* and confirmed_flush_lsn that are much later than expected.
705710
*/
706711
create_logical_replication_slot(NameStr(*dst_name),
707712
plugin,

0 commit comments

Comments
 (0)