From 19515be1ec3818e4c2ae687dca00240e79b6747d Mon Sep 17 00:00:00 2001 From: Nik Samokhvalov Date: Wed, 27 May 2026 10:56:29 -0700 Subject: [PATCH v1 1/3] xlogrecovery: make ConfirmRecoveryPaused and CheckForStandbyTrigger extern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MaybePauseOnLogicalSlotConflict (introduced in the next commit) runs inside ResolveRecoveryConflictWithSnapshot, which is called from the WAL apply path rather than the main recovery loop. Its wait loop must do the same two things recoveryPausesHere() does: 1. Transition RECOVERY_PAUSE_REQUESTED -> RECOVERY_PAUSED so that pg_wal_replay_resume() can release the pause. 2. Check for a promote signal so that pg_promote() does not stall while the startup process is sleeping inside the slot-conflict wait. Both are currently static. Remove the static qualifier and add extern declarations to xlogrecovery.h so standby.c can call them. No behaviour change — only visibility changes. Co-Authored-By: Claude Sonnet 4.6 --- src/backend/access/transam/xlogrecovery.c | 10 ++++++---- src/include/access/xlogrecovery.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index 73b78a83fa7..80282e4689e 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -363,7 +363,8 @@ static bool recoveryStopsAfter(XLogReaderState *record); static char *getRecoveryStopReason(void); static void recoveryPausesHere(bool endOfRecovery); static bool recoveryApplyDelay(XLogReaderState *record); -static void ConfirmRecoveryPaused(void); +/* Exposed for the logical-slot-conflict recovery-pause logic in standby.c. */ +void ConfirmRecoveryPaused(void); static XLogRecord *ReadRecord(XLogPrefetcher *xlogprefetcher, int emode, bool fetching_ckpt, @@ -386,7 +387,8 @@ static int XLogFileRead(XLogSegNo segno, TimeLineID tli, XLogSource source, bool notfoundOk); static int XLogFileReadAnyTLI(XLogSegNo segno, XLogSource source); -static bool CheckForStandbyTrigger(void); +/* Exposed for the logical-slot-conflict recovery-pause logic in standby.c. */ +bool CheckForStandbyTrigger(void); static void SetPromoteIsTriggered(void); static bool HotStandbyActiveInReplay(void); @@ -3083,7 +3085,7 @@ SetRecoveryPause(bool recoveryPause) * Confirm the recovery pause by setting the recovery pause state to * RECOVERY_PAUSED. */ -static void +void ConfirmRecoveryPaused(void) { /* If recovery pause is requested then set it paused */ @@ -4438,7 +4440,7 @@ SetPromoteIsTriggered(void) /* * Check whether a promote request has arrived. */ -static bool +bool CheckForStandbyTrigger(void) { if (LocalPromoteIsTriggered) diff --git a/src/include/access/xlogrecovery.h b/src/include/access/xlogrecovery.h index ba7750dca0b..1683ec14a5a 100644 --- a/src/include/access/xlogrecovery.h +++ b/src/include/access/xlogrecovery.h @@ -213,6 +213,8 @@ extern bool HotStandbyActive(void); extern XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI); extern RecoveryPauseState GetRecoveryPauseState(void); extern void SetRecoveryPause(bool recoveryPause); +extern void ConfirmRecoveryPaused(void); +extern bool CheckForStandbyTrigger(void); extern void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream); extern TimestampTz GetLatestXTime(void); extern TimestampTz GetCurrentChunkReplayStartTime(void); -- 2.50.1 (Apple Git-155)