From 622e52bbd652fc8872448e46c3ca0bc78dd847fe Mon Sep 17 00:00:00 2001 From: Laurenz Albe Date: Tue, 17 Jan 2023 10:38:40 +0100 Subject: [PATCH] Don't show bogus recovery stop time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If target for archive recovery was different from time, the WAL record that ended recovery might not have a timestamp. In that case, the log message at the end of recovery would show a recovery time of midnight on 2000-01-01. Reported-by: Torsten Förtsch Author: Laurenz Albe Discussion: https://postgr.es/m/CAKkG4_kUevPqbmyOfLajx7opAQk6Cvwkvx0HRcFjSPfRPTXanA@mail.gmail.com --- src/backend/access/transam/xlogrecovery.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index bc3c3eb3e7..ce3718ca2d 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -2570,19 +2570,21 @@ recoveryStopsBefore(XLogReaderState *record) recoveryStopLSN = InvalidXLogRecPtr; recoveryStopName[0] = '\0'; - if (isCommit) + /* for targets other than time, we might have no stop time */ + if (recoveryTarget == RECOVERY_TARGET_XID) { ereport(LOG, - (errmsg("recovery stopping before commit of transaction %u, time %s", + (errmsg("recovery stopping before %s of transaction %u, time %s", + (isCommit ? "commit" : "abort"), recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } else { ereport(LOG, - (errmsg("recovery stopping before abort of transaction %u, time %s", - recoveryStopXid, - timestamptz_to_str(recoveryStopTime)))); + (errmsg("recovery stopping before %s of transaction %u", + (isCommit ? "commit" : "abort"), + recoveryStopXid))); } } -- 2.39.0