Commit b5f2f2a7 authored by Simon Riggs's avatar Simon Riggs

Minor changes to recovery pause behaviour.

Change location LOG message so it works each time we pause, not
just for final pause.
Ensure that we pause only if we are in Hot Standby and can connect
to allow us to run resume function. This change supercedes the
code to override parameter recoveryPauseAtTarget to false if not
attempting to enter Hot Standby, which is now removed.
parent ba7d020d
...@@ -5691,6 +5691,10 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) ...@@ -5691,6 +5691,10 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
static void static void
recoveryPausesHere(void) recoveryPausesHere(void)
{ {
ereport(LOG,
(errmsg("recovery has paused"),
errhint("Execute pg_xlog_replay_resume() to continue.")));
while (RecoveryIsPaused()) while (RecoveryIsPaused())
{ {
pg_usleep(1000000L); /* 1000 ms */ pg_usleep(1000000L); /* 1000 ms */
...@@ -6357,13 +6361,6 @@ StartupXLOG(void) ...@@ -6357,13 +6361,6 @@ StartupXLOG(void)
StandbyRecoverPreparedTransactions(false); StandbyRecoverPreparedTransactions(false);
} }
} }
else
{
/*
* Must not pause unless we are going to enter Hot Standby.
*/
recoveryPauseAtTarget = false;
}
/* Initialize resource managers */ /* Initialize resource managers */
for (rmid = 0; rmid <= RM_MAX_ID; rmid++) for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
...@@ -6485,11 +6482,11 @@ StartupXLOG(void) ...@@ -6485,11 +6482,11 @@ StartupXLOG(void)
*/ */
if (recoveryStopsHere(record, &recoveryApply)) if (recoveryStopsHere(record, &recoveryApply))
{ {
if (recoveryPauseAtTarget) /*
* Pause only if users can connect to send a resume message
*/
if (recoveryPauseAtTarget && standbyState == STANDBY_SNAPSHOT_READY)
{ {
ereport(LOG,
(errmsg("recovery has paused"),
errhint("Execute pg_xlog_replay_resume() to continue.")));
SetRecoveryPause(true); SetRecoveryPause(true);
recoveryPausesHere(); recoveryPausesHere();
} }
...@@ -6522,7 +6519,10 @@ StartupXLOG(void) ...@@ -6522,7 +6519,10 @@ StartupXLOG(void)
recoveryPause = xlogctl->recoveryPause; recoveryPause = xlogctl->recoveryPause;
SpinLockRelease(&xlogctl->info_lck); SpinLockRelease(&xlogctl->info_lck);
if (recoveryPause) /*
* Pause only if users can connect to send a resume message
*/
if (recoveryPause && standbyState == STANDBY_SNAPSHOT_READY)
recoveryPausesHere(); recoveryPausesHere();
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment