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

Commit b023650

Browse files
committed
Improve the message logged when recovery is paused.
When recovery target is reached and recovery is paused because of recovery_target_action=pause, executing pg_wal_replay_resume() causes the standby to promote, i.e., the recovery to end. So, in this case, the previous message "Execute pg_wal_replay_resume() to continue" logged was confusing because pg_wal_replay_resume() doesn't cause the recovery to continue. This commit improves the message logged when recovery is paused, and the proper message is output based on what (pg_wal_replay_pause or recovery_target_action) causes recovery to be paused. Author: Sergei Kornilov, revised by Fujii Masao Reviewed-by: Robert Haas Discussion: https://postgr.es/m/19168211580382043@myt5-b646bde4b8f3.qloud-c.yandex.net
1 parent 051fd5e commit b023650

File tree

1 file changed

+17
-8
lines changed
  • src/backend/access/transam

1 file changed

+17
-8
lines changed

src/backend/access/transam/xlog.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ static void validateRecoveryParameters(void);
885885
static void exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog);
886886
static bool recoveryStopsBefore(XLogReaderState *record);
887887
static bool recoveryStopsAfter(XLogReaderState *record);
888-
static void recoveryPausesHere(void);
888+
static void recoveryPausesHere(bool endOfRecovery);
889889
static bool recoveryApplyDelay(XLogReaderState *record);
890890
static void SetLatestXTime(TimestampTz xtime);
891891
static void SetCurrentChunkStartTime(TimestampTz xtime);
@@ -5951,12 +5951,16 @@ recoveryStopsAfter(XLogReaderState *record)
59515951
/*
59525952
* Wait until shared recoveryPause flag is cleared.
59535953
*
5954+
* endOfRecovery is true if the recovery target is reached and
5955+
* the paused state starts at the end of recovery because of
5956+
* recovery_target_action=pause, and false otherwise.
5957+
*
59545958
* XXX Could also be done with shared latch, avoiding the pg_usleep loop.
59555959
* Probably not worth the trouble though. This state shouldn't be one that
59565960
* anyone cares about server power consumption in.
59575961
*/
59585962
static void
5959-
recoveryPausesHere(void)
5963+
recoveryPausesHere(bool endOfRecovery)
59605964
{
59615965
/* Don't pause unless users can connect! */
59625966
if (!LocalHotStandbyActive)
@@ -5966,9 +5970,14 @@ recoveryPausesHere(void)
59665970
if (LocalPromoteIsTriggered)
59675971
return;
59685972

5969-
ereport(LOG,
5970-
(errmsg("recovery has paused"),
5971-
errhint("Execute pg_wal_replay_resume() to continue.")));
5973+
if (endOfRecovery)
5974+
ereport(LOG,
5975+
(errmsg("pausing at the end of recovery"),
5976+
errhint("Execute pg_wal_replay_resume() to promote.")));
5977+
else
5978+
ereport(LOG,
5979+
(errmsg("recovery has paused"),
5980+
errhint("Execute pg_wal_replay_resume() to continue.")));
59725981

59735982
while (RecoveryIsPaused())
59745983
{
@@ -7201,7 +7210,7 @@ StartupXLOG(void)
72017210
* adding another spinlock cycle to prevent that.
72027211
*/
72037212
if (((volatile XLogCtlData *) XLogCtl)->recoveryPause)
7204-
recoveryPausesHere();
7213+
recoveryPausesHere(false);
72057214

72067215
/*
72077216
* Have we reached our recovery target?
@@ -7226,7 +7235,7 @@ StartupXLOG(void)
72267235
* work.
72277236
*/
72287237
if (((volatile XLogCtlData *) XLogCtl)->recoveryPause)
7229-
recoveryPausesHere();
7238+
recoveryPausesHere(false);
72307239
}
72317240

72327241
/* Setup error traceback support for ereport() */
@@ -7400,7 +7409,7 @@ StartupXLOG(void)
74007409

74017410
case RECOVERY_TARGET_ACTION_PAUSE:
74027411
SetRecoveryPause(true);
7403-
recoveryPausesHere();
7412+
recoveryPausesHere(true);
74047413

74057414
/* drop into promote */
74067415

0 commit comments

Comments
 (0)