Skip to content

Commit d96ce41

Browse files
author
hackorum
committed
Apply recovery_stop_after.diffs
1 parent b597835 commit d96ce41

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

src/backend/access/transam/xlogrecovery.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,6 +2552,34 @@ verifyBackupPageConsistency(XLogReaderState *record)
25522552
}
25532553
}
25542554

2555+
/*
2556+
* Support function for recoveryStopsBefore and recoveryStopsAfter. Returns
2557+
* true if we have already reached the recovery target LSN, otherwise returns
2558+
* false.
2559+
*/
2560+
static inline bool
2561+
TargetLSNIsReached(XLogReaderState *record, bool is_before)
2562+
{
2563+
XLogRecPtr targetLsn;
2564+
2565+
Assert(recoveryTarget == RECOVERY_TARGET_LSN);
2566+
2567+
if (is_before)
2568+
{
2569+
if (recoveryTargetInclusive)
2570+
return false;
2571+
2572+
targetLsn = record->ReadRecPtr;
2573+
}
2574+
else
2575+
{
2576+
targetLsn = recoveryTargetInclusive ?
2577+
record->ReadRecPtr : record->EndRecPtr;
2578+
}
2579+
2580+
return targetLsn >= recoveryTargetLSN;
2581+
}
2582+
25552583
/*
25562584
* For point-in-time recovery, this function decides whether we want to
25572585
* stop applying the XLOG before the current record.
@@ -2592,8 +2620,7 @@ recoveryStopsBefore(XLogReaderState *record)
25922620

25932621
/* Check if target LSN has been reached */
25942622
if (recoveryTarget == RECOVERY_TARGET_LSN &&
2595-
!recoveryTargetInclusive &&
2596-
record->ReadRecPtr >= recoveryTargetLSN)
2623+
TargetLSNIsReached(record, true))
25972624
{
25982625
recoveryStopAfter = false;
25992626
recoveryStopXid = InvalidTransactionId;
@@ -2760,12 +2787,11 @@ recoveryStopsAfter(XLogReaderState *record)
27602787

27612788
/* Check if the target LSN has been reached */
27622789
if (recoveryTarget == RECOVERY_TARGET_LSN &&
2763-
recoveryTargetInclusive &&
2764-
record->ReadRecPtr >= recoveryTargetLSN)
2790+
TargetLSNIsReached(record, false))
27652791
{
27662792
recoveryStopAfter = true;
27672793
recoveryStopXid = InvalidTransactionId;
2768-
recoveryStopLSN = record->ReadRecPtr;
2794+
recoveryStopLSN = recoveryTargetInclusive ? record->ReadRecPtr : record->EndRecPtr;
27692795
recoveryStopTime = 0;
27702796
recoveryStopName[0] = '\0';
27712797
ereport(LOG,

0 commit comments

Comments
 (0)