Skip to content

Commit abe2033

Browse files
committed
Log the correct ending timestamp in recovery_target_xid mode.
When ending recovery based on recovery_target_xid matching with recovery_target_inclusive = off, we printed an incorrect timestamp (always 2000-01-01) in the "recovery stopping before ... transaction" log message. This is a consequence of sloppy refactoring in c945af8: the code to fetch recordXtime out of the commit/abort record used to be executed unconditionally, but it was changed to get called only in the RECOVERY_TARGET_TIME case. We need only flip the order of operations to restore the intended behavior. Per report from Torsten Förtsch. Back-patch to all supported branches. Discussion: https://postgr.es/m/CAKkG4_kUevPqbmyOfLajx7opAQk6Cvwkvx0HRcFjSPfRPTXanA@mail.gmail.com
1 parent 49e3a5e commit abe2033

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/backend/access/transam/xlogrecovery.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,8 +2544,13 @@ recoveryStopsBefore(XLogReaderState *record)
25442544
stopsHere = (recordXid == recoveryTargetXid);
25452545
}
25462546

2547-
if (recoveryTarget == RECOVERY_TARGET_TIME &&
2548-
getRecordTimestamp(record, &recordXtime))
2547+
/*
2548+
* Note: we must fetch recordXtime regardless of recoveryTarget setting.
2549+
* We don't expect getRecordTimestamp ever to fail, since we already know
2550+
* this is a commit or abort record; but test its result anyway.
2551+
*/
2552+
if (getRecordTimestamp(record, &recordXtime) &&
2553+
recoveryTarget == RECOVERY_TARGET_TIME)
25492554
{
25502555
/*
25512556
* There can be many transactions that share the same commit time, so

0 commit comments

Comments
 (0)