On 2020/04/01 19:37, Fujii Masao wrote:


On 2020/04/01 18:56, movead...@highgo.ca wrote:

 >This happens because the startup process detects the trigger file
after pg_wal_replay_pause() succeeds, and then make the recovery
get out of the paused state.
Yes that is.

 >It might be problematic to end the paused
state silently? So, to make the situation less confusing, what about
emitting a log message when ending the paused state because of
the promotion?
But where to emit it? I think it not so good by emitting to log file,
because the user will not check it everytime.

Yeah, I'm thinking to emit the message to log file, like the startup process
does in other places :)

So I'd like to propose the attached patch. The patch changes the message
logged when a promotion is requested, based on whether the recovery is
in paused state or not.

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 977d448f50..c7255ca24c 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -12472,7 +12472,12 @@ CheckForStandbyTrigger(void)
                        fast_promote = false;
                }
 
-               ereport(LOG, (errmsg("received promote request")));
+               if (RecoveryIsPaused())
+                       ereport(LOG,
+                                       (errmsg("received promote request while 
recovery is paused"),
+                                        errdetail("The paused state ends and 
the promotion continues.")));
+               else
+                       ereport(LOG, (errmsg("received promote request")));
 
                ResetPromoteSignaled();
                SetPromoteIsTriggered();
@@ -12484,8 +12489,14 @@ CheckForStandbyTrigger(void)
 
        if (stat(PromoteTriggerFile, &stat_buf) == 0)
        {
-               ereport(LOG,
-                               (errmsg("promote trigger file found: %s", 
PromoteTriggerFile)));
+               if (RecoveryIsPaused())
+                       ereport(LOG,
+                                       (errmsg("promote trigger file found 
while recovery is paused: %s",
+                                                       PromoteTriggerFile),
+                                        errdetail("The paused state ends and 
the promotion continues.")));
+               else
+                       ereport(LOG,
+                                       (errmsg("promote trigger file found: 
%s", PromoteTriggerFile)));
                unlink(PromoteTriggerFile);
                SetPromoteIsTriggered();
                fast_promote = true;

Reply via email to