diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-01-19 12:23:20 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-01-19 12:23:20 -0500 |
commit | abe203304e1567c5938b348a8d9c5ad9b909742d (patch) | |
tree | 584da40565ff4e83d2310dfc98258f8505eccd75 /src/backend/access/transam/xlogrecovery.c | |
parent | 49e3a5e7149d3f676318f2222aaab30613f8dc59 (diff) | |
download | postgresql-abe203304e1567c5938b348a8d9c5ad9b909742d.tar.gz postgresql-abe203304e1567c5938b348a8d9c5ad9b909742d.zip |
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
c945af80c: 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
Diffstat (limited to 'src/backend/access/transam/xlogrecovery.c')
-rw-r--r-- | src/backend/access/transam/xlogrecovery.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index b51173a8c09..958e85366c1 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -2544,8 +2544,13 @@ recoveryStopsBefore(XLogReaderState *record) stopsHere = (recordXid == recoveryTargetXid); } - if (recoveryTarget == RECOVERY_TARGET_TIME && - getRecordTimestamp(record, &recordXtime)) + /* + * Note: we must fetch recordXtime regardless of recoveryTarget setting. + * We don't expect getRecordTimestamp ever to fail, since we already know + * this is a commit or abort record; but test its result anyway. + */ + if (getRecordTimestamp(record, &recordXtime) && + recoveryTarget == RECOVERY_TARGET_TIME) { /* * There can be many transactions that share the same commit time, so |