mirror of
https://github.com/postgres/postgres.git
synced 2026-04-14 05:27:20 -04:00
Previously, on standby promotion, the startup process sent SIGUSR1 to the slotsync worker (or a backend performing slot synchronization) and waited for it to exit. This worked in most cases, but if the process was blocked waiting for a response from the primary (e.g., due to a network failure), SIGUSR1 would not interrupt the wait. As a result, the process could remain stuck, causing the startup process to wait for a long time and delaying promotion. This commit fixes the issue by introducing a new procsignal reason, PROCSIG_SLOTSYNC_MESSAGE. On promotion, the startup process sends this signal, and the handler sets interrupt flags so the process exits (or errors out) promptly at CHECK_FOR_INTERRUPTS(), allowing promotion to complete without delay. Backpatch to v17, where slotsync was introduced. Author: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/CAHGQGwFzNYroAxSoyJhqTU-pH=t4Ej6RyvhVmBZ91Exj_TPMMQ@mail.gmail.com Backpatch-through: 17
43 lines
1.3 KiB
C
43 lines
1.3 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* slotsync.h
|
|
* Exports for slot synchronization.
|
|
*
|
|
* Portions Copyright (c) 2016-2026, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/replication/slotsync.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef SLOTSYNC_H
|
|
#define SLOTSYNC_H
|
|
|
|
#include <signal.h>
|
|
|
|
#include "replication/walreceiver.h"
|
|
|
|
extern PGDLLIMPORT bool sync_replication_slots;
|
|
|
|
/* Interrupt flag set by HandleSlotSyncMessageInterrupt() */
|
|
extern PGDLLIMPORT volatile sig_atomic_t SlotSyncShutdownPending;
|
|
|
|
/*
|
|
* GUCs needed by slot sync worker to connect to the primary
|
|
* server and carry on with slots synchronization.
|
|
*/
|
|
extern PGDLLIMPORT char *PrimaryConnInfo;
|
|
extern PGDLLIMPORT char *PrimarySlotName;
|
|
|
|
extern char *CheckAndGetDbnameFromConninfo(void);
|
|
extern bool ValidateSlotSyncParams(int elevel);
|
|
|
|
pg_noreturn extern void ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len);
|
|
|
|
extern void ShutDownSlotSync(void);
|
|
extern bool SlotSyncWorkerCanRestart(void);
|
|
extern bool IsSyncingReplicationSlots(void);
|
|
extern void SyncReplicationSlots(WalReceiverConn *wrconn);
|
|
extern void HandleSlotSyncMessageInterrupt(void);
|
|
extern void ProcessSlotSyncMessage(void);
|
|
|
|
#endif /* SLOTSYNC_H */
|