Remove unnecessary call to ReadCheckpointRecord().
It should always be the case that the last checkpoint record is still readable, because otherwise, a crash would leave us in a situation from which we can't recover. Therefore the test removed by this patch should always succeed. For it to fail, either there has to be a serious bug in the code someplace, or the user has to be manually modifying pg_wal while crash recovery is running. If it's the first one, we should fix the bug. If it's the second one, they should stop, or anyway they're doing so at their own risk. In neither case does a full checkpoint instead of an end-of-recovery record seem like a clear winner. Furthermore, rarely-taken code paths are particularly vulnerable to bugs, so let's simplify by getting rid of this one. Discussion: http://postgr.es/m/CA+TgmoYmw==TOJ6EzYb_vcjyS09NkzrVKSyBKUUyo1zBEaJASA@mail.gmail.com
This commit is contained in:
parent
3df93a6659
commit
1d919de5eb
|
@ -7916,34 +7916,22 @@ StartupXLOG(void)
|
||||||
if (bgwriterLaunched)
|
if (bgwriterLaunched)
|
||||||
{
|
{
|
||||||
if (LocalPromoteIsTriggered)
|
if (LocalPromoteIsTriggered)
|
||||||
{
|
|
||||||
checkPointLoc = ControlFile->checkPoint;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Confirm the last checkpoint is available for us to recover
|
|
||||||
* from if we fail.
|
|
||||||
*/
|
|
||||||
record = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, false);
|
|
||||||
if (record != NULL)
|
|
||||||
{
|
{
|
||||||
promoted = true;
|
promoted = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert a special WAL record to mark the end of
|
* Insert a special WAL record to mark the end of recovery,
|
||||||
* recovery, since we aren't doing a checkpoint. That
|
* since we aren't doing a checkpoint. That means that the
|
||||||
* means that the checkpointer process may likely be in
|
* checkpointer process may likely be in the middle of a
|
||||||
* the middle of a time-smoothed restartpoint and could
|
* time-smoothed restartpoint and could continue to be for
|
||||||
* continue to be for minutes after this. That sounds
|
* minutes after this. That sounds strange, but the effect is
|
||||||
* strange, but the effect is roughly the same and it
|
* roughly the same and it would be stranger to try to come
|
||||||
* would be stranger to try to come out of the
|
* out of the restartpoint and then checkpoint. We request a
|
||||||
* restartpoint and then checkpoint. We request a
|
|
||||||
* checkpoint later anyway, just for safety.
|
* checkpoint later anyway, just for safety.
|
||||||
*/
|
*/
|
||||||
CreateEndOfRecoveryRecord();
|
CreateEndOfRecoveryRecord();
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
if (!promoted)
|
|
||||||
RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
|
RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
|
||||||
CHECKPOINT_IMMEDIATE |
|
CHECKPOINT_IMMEDIATE |
|
||||||
CHECKPOINT_WAIT);
|
CHECKPOINT_WAIT);
|
||||||
|
|
Loading…
Reference in New Issue