summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlog.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 616571bb2c4..9aecad60209 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -402,10 +402,14 @@ typedef struct XLogCtlData
XLogRecPtr lastCheckPointRecPtr;
CheckPoint lastCheckPoint;
- /* end+1 of the last record replayed (or being replayed) */
+ /*
+ * lastReplayedEndRecPtr points to end+1 of the last record successfully
+ * replayed. When we're currently replaying a record, ie. in a redo
+ * function, replayEndRecPtr points to the end+1 of the record being
+ * replayed, otherwise it's equal to lastReplayedEndRecPtr.
+ */
+ XLogRecPtr lastReplayedEndRecPtr;
XLogRecPtr replayEndRecPtr;
- /* end+1 of the last record replayed */
- XLogRecPtr recoveryLastRecPtr;
/* timestamp of last COMMIT/ABORT record replayed (or being replayed) */
TimestampTz recoveryLastXTime;
@@ -6161,7 +6165,7 @@ StartupXLOG(void)
}
/*
- * Initialize shared replayEndRecPtr, recoveryLastRecPtr, and
+ * Initialize shared replayEndRecPtr, lastReplayedEndRecPtr, and
* recoveryLastXTime.
*
* This is slightly confusing if we're starting from an online
@@ -6174,7 +6178,7 @@ StartupXLOG(void)
*/
SpinLockAcquire(&xlogctl->info_lck);
xlogctl->replayEndRecPtr = ReadRecPtr;
- xlogctl->recoveryLastRecPtr = EndRecPtr;
+ xlogctl->lastReplayedEndRecPtr = EndRecPtr;
xlogctl->recoveryLastXTime = 0;
SpinLockRelease(&xlogctl->info_lck);
@@ -6263,9 +6267,6 @@ StartupXLOG(void)
/* Handle interrupt signals of startup process */
HandleStartupProcInterrupts();
- /* Allow read-only connections if we're consistent now */
- CheckRecoveryConsistency();
-
/*
* Have we reached our recovery target?
*/
@@ -6313,15 +6314,18 @@ StartupXLOG(void)
error_context_stack = errcontext.previous;
/*
- * Update shared recoveryLastRecPtr after this record has been
- * replayed.
+ * Update lastReplayedEndRecPtr after this record has been
+ * successfully replayed.
*/
SpinLockAcquire(&xlogctl->info_lck);
- xlogctl->recoveryLastRecPtr = EndRecPtr;
+ xlogctl->lastReplayedEndRecPtr = EndRecPtr;
SpinLockRelease(&xlogctl->info_lck);
LastRec = ReadRecPtr;
+ /* Allow read-only connections if we're consistent now */
+ CheckRecoveryConsistency();
+
record = ReadRecord(NULL, LOG, false);
} while (record != NULL && recoveryContinue);
@@ -6661,13 +6665,14 @@ CheckRecoveryConsistency(void)
* Have we passed our safe starting point?
*/
if (!reachedConsistency &&
- XLByteLE(minRecoveryPoint, EndRecPtr) &&
+ XLByteLE(minRecoveryPoint, XLogCtl->lastReplayedEndRecPtr) &&
XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
{
reachedConsistency = true;
ereport(LOG,
(errmsg("consistent recovery state reached at %X/%X",
- EndRecPtr.xlogid, EndRecPtr.xrecoff)));
+ XLogCtl->lastReplayedEndRecPtr.xlogid,
+ XLogCtl->lastReplayedEndRecPtr.xrecoff)));
}
/*
@@ -8967,7 +8972,7 @@ pg_last_xlog_replay_location(PG_FUNCTION_ARGS)
char location[MAXFNAMELEN];
SpinLockAcquire(&xlogctl->info_lck);
- recptr = xlogctl->recoveryLastRecPtr;
+ recptr = xlogctl->lastReplayedEndRecPtr;
SpinLockRelease(&xlogctl->info_lck);
if (recptr.xlogid == 0 && recptr.xrecoff == 0)