Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb669f41

Browse files
committed
Fix checkpoint after fast promotion.
The intention was to request a regular online checkpoint immediately afterend of recovery, when performing "fast promotion". However, because thecheckpoint was requested before other backends were allowed to write WAL,the checkpointer process performed a restartpoint rather than a checkpoint.Delay the RequestCheckPoint call until after recovery has truly ended, sothat you get a real checkpoint.
1 parent7803e93 commitb669f41

File tree

1 file changed

+16
-15
lines changed
  • src/backend/access/transam

1 file changed

+16
-15
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4731,6 +4731,7 @@ StartupXLOG(void)
47314731
DBStatedbstate_at_startup;
47324732
XLogReaderState*xlogreader;
47334733
XLogPageReadPrivateprivate;
4734+
boolfast_promoted= false;
47344735

47354736
/*
47364737
* Read control file and check XLOG status looks valid.
@@ -5781,15 +5782,13 @@ StartupXLOG(void)
57815782
* assigning a new TLI, using a shutdown checkpoint allows us to have
57825783
* the rule that TLI only changes in shutdown checkpoints, which
57835784
* allows some extra error checking in xlog_redo.
5785+
*
5786+
* In fast promotion, only create a lightweight end-of-recovery record
5787+
* instead of a full checkpoint. A checkpoint is requested later, after
5788+
* we're fully out of recovery mode and already accepting queries.
57845789
*/
57855790
if (bgwriterLaunched)
57865791
{
5787-
boolcheckpoint_wait= true;
5788-
5789-
/*
5790-
* If we've been explicitly promoted with fast option,
5791-
* end of recovery without a checkpoint if possible.
5792-
*/
57935792
if (fast_promote)
57945793
{
57955794
checkPointLoc=ControlFile->prevCheckPoint;
@@ -5802,22 +5801,15 @@ StartupXLOG(void)
58025801
record=ReadCheckpointRecord(xlogreader,checkPointLoc,1, false);
58035802
if (record!=NULL)
58045803
{
5805-
checkpoint_wait=false;
5804+
fast_promoted=true;
58065805
CreateEndOfRecoveryRecord();
58075806
}
58085807
}
58095808

5810-
/*
5811-
* In most cases we will wait for a full checkpoint to complete.
5812-
*
5813-
* If not, issue a normal, non-immediate checkpoint but don't wait.
5814-
*/
5815-
if (checkpoint_wait)
5809+
if (!fast_promoted)
58165810
RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
58175811
CHECKPOINT_IMMEDIATE |
58185812
CHECKPOINT_WAIT);
5819-
else
5820-
RequestCheckpoint(0);/* No flags */
58215813
}
58225814
else
58235815
CreateCheckPoint(CHECKPOINT_END_OF_RECOVERY |CHECKPOINT_IMMEDIATE);
@@ -5925,6 +5917,15 @@ StartupXLOG(void)
59255917
* wal sender processes to notice that we've been promoted.
59265918
*/
59275919
WalSndWakeup();
5920+
5921+
/*
5922+
* If this was a fast promotion, request an (online) checkpoint now. This
5923+
* isn't required for consistency, but the last restartpoint might be far
5924+
* back, and in case of a crash, recovering from it might take a longer
5925+
* than is appropriate now that we're not in standby mode anymore.
5926+
*/
5927+
if (fast_promoted)
5928+
RequestCheckpoint(0);
59285929
}
59295930

59305931
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp