On 2020/03/10 2:27, Robert Haas wrote:
On Mon, Mar 9, 2020 at 12:03 PM Fujii Masao <masao.fu...@oss.nttdata.com> wrote:
I started the discussion about the topic very related to this.
I'm thinking to apply the change that Sergei proposes after applying
the patch I attached in this thread.
https://postgr.es/m/00c194b2-dbbb-2e8a-5b39-13f14048e...@oss.nttdata.com
I think it would be good to change the primary message, not just the hint. e.g.
LOG: pausing at end of recovery
HINT: Execute pg_wal_replay_resume() to promote.
vs.
LOG: recovery has paused
HINT: Execute pg_wal_replay_resume() to continue.
Looks good to me.
Attached is the updated version of the patch.
This is based on Sergei's patch.
Regards,
--
Fujii Masao
NTT DATA CORPORATION
Advanced Platform Technology Group
Research and Development Headquarters
diff --git a/src/backend/access/transam/xlog.c
b/src/backend/access/transam/xlog.c
index 7621fc05e2..3c29581b63 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -877,7 +877,7 @@ static void validateRecoveryParameters(void);
static void exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog);
static bool recoveryStopsBefore(XLogReaderState *record);
static bool recoveryStopsAfter(XLogReaderState *record);
-static void recoveryPausesHere(void);
+static void recoveryPausesHere(bool endOfRecovery);
static bool recoveryApplyDelay(XLogReaderState *record);
static void SetLatestXTime(TimestampTz xtime);
static void SetCurrentChunkStartTime(TimestampTz xtime);
@@ -5943,12 +5943,16 @@ recoveryStopsAfter(XLogReaderState *record)
/*
* Wait until shared recoveryPause flag is cleared.
*
+ * endOfRecovery is true if the recovery target is reached and
+ * the paused state starts at the end of recovery because of
+ * recovery_target_action=pause, and false otherwise.
+ *
* XXX Could also be done with shared latch, avoiding the pg_usleep loop.
* Probably not worth the trouble though. This state shouldn't be one that
* anyone cares about server power consumption in.
*/
static void
-recoveryPausesHere(void)
+recoveryPausesHere(bool endOfRecovery)
{
/* Don't pause unless users can connect! */
if (!LocalHotStandbyActive)
@@ -5958,9 +5962,14 @@ recoveryPausesHere(void)
if (LocalPromoteIsTriggered)
return;
- ereport(LOG,
- (errmsg("recovery has paused"),
- errhint("Execute pg_wal_replay_resume() to
continue.")));
+ if (endOfRecovery)
+ ereport(LOG,
+ (errmsg("pausing at the end of recovery"),
+ errhint("Execute pg_wal_replay_resume() to
promote.")));
+ else
+ ereport(LOG,
+ (errmsg("recovery has paused"),
+ errhint("Execute pg_wal_replay_resume() to
continue.")));
while (RecoveryIsPaused())
{
@@ -7141,7 +7150,7 @@ StartupXLOG(void)
* adding another spinlock cycle to prevent
that.
*/
if (((volatile XLogCtlData *)
XLogCtl)->recoveryPause)
- recoveryPausesHere();
+ recoveryPausesHere(false);
/*
* Have we reached our recovery target?
@@ -7166,7 +7175,7 @@ StartupXLOG(void)
* work.
*/
if (((volatile XLogCtlData *)
XLogCtl)->recoveryPause)
- recoveryPausesHere();
+ recoveryPausesHere(false);
}
/* Setup error traceback support for ereport()
*/
@@ -7340,7 +7349,7 @@ StartupXLOG(void)
case RECOVERY_TARGET_ACTION_PAUSE:
SetRecoveryPause(true);
- recoveryPausesHere();
+ recoveryPausesHere(true);
/* drop into promote */