Skip to content

Commit 2314bae

Browse files
committed
Fix recoveryLastXTime logic so that it actually does what one would expect.
Per gripe from Kevin Grittner. Backpatch to 8.3, where the bug was introduced.
1 parent d50966a commit 2314bae

File tree

1 file changed

+12
-4
lines changed
  • src/backend/access/transam

1 file changed

+12
-4
lines changed

src/backend/access/transam/xlog.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.319 2008/09/23 09:20:35 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.320 2008/10/30 04:06:16 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -4698,6 +4698,9 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
46984698
*
46994699
* Returns TRUE if we are stopping, FALSE otherwise. On TRUE return,
47004700
* *includeThis is set TRUE if we should apply this record before stopping.
4701+
*
4702+
* We also track the timestamp of the latest applied COMMIT/ABORT record
4703+
* in recoveryLastXTime, for logging purposes.
47014704
* Also, some information is saved in recoveryStopXid et al for use in
47024705
* annotating the new timeline's history file.
47034706
*/
@@ -4729,12 +4732,12 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
47294732
else
47304733
return false;
47314734

4732-
/* Remember the most recent COMMIT/ABORT time for logging purposes */
4733-
recoveryLastXTime = recordXtime;
4734-
47354735
/* Do we have a PITR target at all? */
47364736
if (!recoveryTarget)
4737+
{
4738+
recoveryLastXTime = recordXtime;
47374739
return false;
4740+
}
47384741

47394742
if (recoveryTargetExact)
47404743
{
@@ -4798,7 +4801,12 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
47984801
recoveryStopXid,
47994802
timestamptz_to_str(recoveryStopTime))));
48004803
}
4804+
4805+
if (recoveryStopAfter)
4806+
recoveryLastXTime = recordXtime;
48014807
}
4808+
else
4809+
recoveryLastXTime = recordXtime;
48024810

48034811
return stopsHere;
48044812
}

0 commit comments

Comments
 (0)