Skip to content

Commit db08e8c

Browse files
author
Amit Kapila
committed
Post-commit review fixes for slot synchronization.
Allow pg_sync_replication_slots() to error out during promotion of standby. This makes the behavior of the SQL function consistent with the slot sync worker. We also ensured that pg_sync_replication_slots() cannot be executed if sync_replication_slots is enabled and the slotsync worker is already running to perform the synchronization of slots. Previously, it would have succeeded in cases when the worker is idle and failed when it is performing sync which could confuse users. This patch fixes another issue in the slot sync worker where SignalHandlerForShutdownRequest() needs to be registered *before* setting SlotSyncCtx->pid, otherwise, the slotsync worker could miss handling SIGINT sent by the startup process(ShutDownSlotSync) if it is sent before worker could register SignalHandlerForShutdownRequest(). To be consistent, all signal handlers' registration is moved to a prior location before we set the worker's pid. Ensure that we clean up synced temp slots at the end of pg_sync_replication_slots() to avoid such slots being left over after promotion. Ensure that ShutDownSlotSync() captures SlotSyncCtx->pid under spinlock to avoid accessing invalid value as it can be reset by concurrent slot sync exit due to an error. Author: Shveta Malik Reviewed-by: Hou Zhijie, Bertrand Drouvot, Amit Kapila, Masahiko Sawada Discussion: https://postgr.es/m/CAJpy0uBefXUS_TSz=oxmYKHdg-fhxUT0qfjASW3nmqnzVC3p6A@mail.gmail.com
1 parent 0afa288 commit db08e8c

File tree

6 files changed

+206
-98
lines changed

6 files changed

+206
-98
lines changed

doc/src/sgml/func.sgml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29349,6 +29349,10 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
2934929349
standby server. Temporary synced slots, if any, cannot be used for
2935029350
logical decoding and must be dropped after promotion. See
2935129351
<xref linkend="logicaldecoding-replication-slots-synchronization"/> for details.
29352+
Note that this function cannot be executed if
29353+
<link linkend="guc-sync-replication-slots"><varname>
29354+
sync_replication_slots</varname></link> is enabled and the slotsync
29355+
worker is already running to perform the synchronization of slots.
2935229356
</para>
2935329357

2935429358
<caution>

0 commit comments

Comments
 (0)