Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1d919de

Browse files
committed
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
1 parent 3df93a6 commit 1d919de

File tree

1 file changed

+11
-23
lines changed
  • src/backend/access/transam

1 file changed

+11
-23
lines changed

src/backend/access/transam/xlog.c

+11-23
Original file line numberDiff line numberDiff line change
@@ -7917,33 +7917,21 @@ StartupXLOG(void)
79177917
{
79187918
if (LocalPromoteIsTriggered)
79197919
{
7920-
checkPointLoc = ControlFile->checkPoint;
7920+
promoted = true;
79217921

79227922
/*
7923-
* Confirm the last checkpoint is available for us to recover
7924-
* from if we fail.
7923+
* Insert a special WAL record to mark the end of recovery,
7924+
* since we aren't doing a checkpoint. That means that the
7925+
* checkpointer process may likely be in the middle of a
7926+
* time-smoothed restartpoint and could continue to be for
7927+
* minutes after this. That sounds strange, but the effect is
7928+
* roughly the same and it would be stranger to try to come
7929+
* out of the restartpoint and then checkpoint. We request a
7930+
* checkpoint later anyway, just for safety.
79257931
*/
7926-
record = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, false);
7927-
if (record != NULL)
7928-
{
7929-
promoted = true;
7930-
7931-
/*
7932-
* Insert a special WAL record to mark the end of
7933-
* recovery, since we aren't doing a checkpoint. That
7934-
* means that the checkpointer process may likely be in
7935-
* the middle of a time-smoothed restartpoint and could
7936-
* continue to be for minutes after this. That sounds
7937-
* strange, but the effect is roughly the same and it
7938-
* would be stranger to try to come out of the
7939-
* restartpoint and then checkpoint. We request a
7940-
* checkpoint later anyway, just for safety.
7941-
*/
7942-
CreateEndOfRecoveryRecord();
7943-
}
7932+
CreateEndOfRecoveryRecord();
79447933
}
7945-
7946-
if (!promoted)
7934+
else
79477935
RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
79487936
CHECKPOINT_IMMEDIATE |
79497937
CHECKPOINT_WAIT);

0 commit comments

Comments
 (0)