@@ -299,9 +299,6 @@ bool wal_receiver_create_temp_slot = false;
299
299
/* are we currently in standby mode? */
300
300
bool StandbyMode = false;
301
301
302
- /* whether request for fast promotion has been made yet */
303
- static bool fast_promote = false;
304
-
305
302
/*
306
303
* if recoveryStopsBefore/After returns true, it saves information of the stop
307
304
* point here
@@ -6322,7 +6319,7 @@ StartupXLOG(void)
6322
6319
DBState dbstate_at_startup ;
6323
6320
XLogReaderState * xlogreader ;
6324
6321
XLogPageReadPrivate private ;
6325
- bool fast_promoted = false;
6322
+ bool promoted = false;
6326
6323
struct stat st ;
6327
6324
6328
6325
/*
@@ -7727,14 +7724,14 @@ StartupXLOG(void)
7727
7724
* the rule that TLI only changes in shutdown checkpoints, which
7728
7725
* allows some extra error checking in xlog_redo.
7729
7726
*
7730
- * In fast promotion, only create a lightweight end-of-recovery record
7727
+ * In promotion, only create a lightweight end-of-recovery record
7731
7728
* instead of a full checkpoint. A checkpoint is requested later,
7732
7729
* after we're fully out of recovery mode and already accepting
7733
7730
* queries.
7734
7731
*/
7735
7732
if (bgwriterLaunched )
7736
7733
{
7737
- if (fast_promote )
7734
+ if (LocalPromoteIsTriggered )
7738
7735
{
7739
7736
checkPointLoc = ControlFile -> checkPoint ;
7740
7737
@@ -7745,7 +7742,7 @@ StartupXLOG(void)
7745
7742
record = ReadCheckpointRecord (xlogreader , checkPointLoc , 1 , false);
7746
7743
if (record != NULL )
7747
7744
{
7748
- fast_promoted = true;
7745
+ promoted = true;
7749
7746
7750
7747
/*
7751
7748
* Insert a special WAL record to mark the end of
@@ -7762,7 +7759,7 @@ StartupXLOG(void)
7762
7759
}
7763
7760
}
7764
7761
7765
- if (!fast_promoted )
7762
+ if (!promoted )
7766
7763
RequestCheckpoint (CHECKPOINT_END_OF_RECOVERY |
7767
7764
CHECKPOINT_IMMEDIATE |
7768
7765
CHECKPOINT_WAIT );
@@ -7953,12 +7950,12 @@ StartupXLOG(void)
7953
7950
WalSndWakeup ();
7954
7951
7955
7952
/*
7956
- * If this was a fast promotion, request an (online) checkpoint now. This
7953
+ * If this was a promotion, request an (online) checkpoint now. This
7957
7954
* isn't required for consistency, but the last restartpoint might be far
7958
7955
* back, and in case of a crash, recovering from it might take a longer
7959
7956
* than is appropriate now that we're not in standby mode anymore.
7960
7957
*/
7961
- if (fast_promoted )
7958
+ if (promoted )
7962
7959
RequestCheckpoint (CHECKPOINT_FORCE );
7963
7960
}
7964
7961
@@ -12592,29 +12589,10 @@ CheckForStandbyTrigger(void)
12592
12589
if (LocalPromoteIsTriggered )
12593
12590
return true;
12594
12591
12595
- if (IsPromoteSignaled ())
12592
+ if (IsPromoteSignaled () && CheckPromoteSignal () )
12596
12593
{
12597
- /*
12598
- * In 9.1 and 9.2 the postmaster unlinked the promote file inside the
12599
- * signal handler. It now leaves the file in place and lets the
12600
- * Startup process do the unlink. This allows Startup to know whether
12601
- * it should create a full checkpoint before starting up (fallback
12602
- * mode). Fast promotion takes precedence.
12603
- */
12604
- if (stat (PROMOTE_SIGNAL_FILE , & stat_buf ) == 0 )
12605
- {
12606
- unlink (PROMOTE_SIGNAL_FILE );
12607
- unlink (FALLBACK_PROMOTE_SIGNAL_FILE );
12608
- fast_promote = true;
12609
- }
12610
- else if (stat (FALLBACK_PROMOTE_SIGNAL_FILE , & stat_buf ) == 0 )
12611
- {
12612
- unlink (FALLBACK_PROMOTE_SIGNAL_FILE );
12613
- fast_promote = false;
12614
- }
12615
-
12616
12594
ereport (LOG , (errmsg ("received promote request" )));
12617
-
12595
+ RemovePromoteSignalFiles ();
12618
12596
ResetPromoteSignaled ();
12619
12597
SetPromoteIsTriggered ();
12620
12598
return true;
@@ -12629,7 +12607,6 @@ CheckForStandbyTrigger(void)
12629
12607
(errmsg ("promote trigger file found: %s" , PromoteTriggerFile )));
12630
12608
unlink (PromoteTriggerFile );
12631
12609
SetPromoteIsTriggered ();
12632
- fast_promote = true;
12633
12610
return true;
12634
12611
}
12635
12612
else if (errno != ENOENT )
@@ -12648,20 +12625,17 @@ void
12648
12625
RemovePromoteSignalFiles (void )
12649
12626
{
12650
12627
unlink (PROMOTE_SIGNAL_FILE );
12651
- unlink (FALLBACK_PROMOTE_SIGNAL_FILE );
12652
12628
}
12653
12629
12654
12630
/*
12655
- * Check to see if a promote request has arrived. Should be
12656
- * called by postmaster after receiving SIGUSR1.
12631
+ * Check to see if a promote request has arrived.
12657
12632
*/
12658
12633
bool
12659
12634
CheckPromoteSignal (void )
12660
12635
{
12661
12636
struct stat stat_buf ;
12662
12637
12663
- if (stat (PROMOTE_SIGNAL_FILE , & stat_buf ) == 0 ||
12664
- stat (FALLBACK_PROMOTE_SIGNAL_FILE , & stat_buf ) == 0 )
12638
+ if (stat (PROMOTE_SIGNAL_FILE , & stat_buf ) == 0 )
12665
12639
return true;
12666
12640
12667
12641
return false;
0 commit comments