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

Commit8e1e827

Browse files
committed
Check if we've reached end-of-backup point also if no redo is required.
If you restored from a backup taken from a standby, and the last record inthe backup is the checkpoint record, ie. there is no redo required exceptfor the checkpoint record, we would fail to notice that we've reached theend-of-backup point, and the database is consistent. The result was anerror "WAL ends before end of online backup". To fix, move thehave-we-reached-end-of-backup check into CheckRecoveryConsistency(), whichis already responsible for similar checks with minRecoveryPoint, and iscalled in the right places.Backpatch to 9.2, this check and bug did not exist before that.
1 parent31e0349 commit8e1e827

File tree

1 file changed

+28
-21
lines changed
  • src/backend/access/transam

1 file changed

+28
-21
lines changed

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

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6776,27 +6776,6 @@ StartupXLOG(void)
67766776
/* Pop the error context stack */
67776777
error_context_stack=errcontext.previous;
67786778

6779-
if (!XLogRecPtrIsInvalid(ControlFile->backupEndPoint)&&
6780-
XLByteLE(ControlFile->backupEndPoint,EndRecPtr))
6781-
{
6782-
/*
6783-
* We have reached the end of base backup, the point where
6784-
* the minimum recovery point in pg_control indicates. The
6785-
* data on disk is now consistent. Reset backupStartPoint
6786-
* and backupEndPoint.
6787-
*/
6788-
elog(DEBUG1,"end of backup reached");
6789-
6790-
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
6791-
6792-
MemSet(&ControlFile->backupStartPoint,0,sizeof(XLogRecPtr));
6793-
MemSet(&ControlFile->backupEndPoint,0,sizeof(XLogRecPtr));
6794-
ControlFile->backupEndRequired= false;
6795-
UpdateControlFile();
6796-
6797-
LWLockRelease(ControlFileLock);
6798-
}
6799-
68006779
/*
68016780
* Update lastReplayedEndRecPtr after this record has been
68026781
* successfully replayed.
@@ -7176,6 +7155,34 @@ CheckRecoveryConsistency(void)
71767155
if (XLogRecPtrIsInvalid(minRecoveryPoint))
71777156
return;
71787157

7158+
/*
7159+
* Have we reached the point where our base backup was completed?
7160+
*/
7161+
if (!XLogRecPtrIsInvalid(ControlFile->backupEndPoint)&&
7162+
XLByteLE(ControlFile->backupEndPoint,EndRecPtr))
7163+
{
7164+
/*
7165+
* We have reached the end of base backup, as indicated by pg_control.
7166+
* The data on disk is now consistent. Reset backupStartPoint and
7167+
* backupEndPoint, and update minRecoveryPoint to make sure we don't
7168+
* allow starting up at an earlier point even if recovery is stopped
7169+
* and restarted soon after this.
7170+
*/
7171+
elog(DEBUG1,"end of backup reached");
7172+
7173+
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
7174+
7175+
if (XLByteLT(ControlFile->minRecoveryPoint,EndRecPtr))
7176+
ControlFile->minRecoveryPoint=EndRecPtr;
7177+
7178+
MemSet(&ControlFile->backupStartPoint,0,sizeof(XLogRecPtr));
7179+
MemSet(&ControlFile->backupEndPoint,0,sizeof(XLogRecPtr));
7180+
ControlFile->backupEndRequired= false;
7181+
UpdateControlFile();
7182+
7183+
LWLockRelease(ControlFileLock);
7184+
}
7185+
71797186
/*
71807187
* Have we passed our safe starting point? Note that minRecoveryPoint
71817188
* is known to be incorrectly set if ControlFile->backupEndRequired,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp