From 9678d0cd928c58e4a3d038c8aa4c191f5bdddbe7 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 28 Feb 2024 21:45:39 +0000 Subject: Add checkpoint/redo LSNs to recovery errors. When backup_label is present the LSNs are already output in a log message, but it still seems like a good idea to repeat them. When backup_label is not present, the checkpoint LSN is not logged unless backup recovery is in progress or the checkpoint is found. In the case where a backup is restored but the backup_label is missing, the checkpoint LSN is not logged so it is useful for debugging to have it in the error message. --- src/backend/access/transam/xlogrecovery.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index d73a49b3e8..baf1765f5e 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -647,7 +647,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, if (!ReadRecord(xlogprefetcher, LOG, false, checkPoint.ThisTimeLineID)) ereport(FATAL, - (errmsg("could not find redo location referenced by checkpoint record"), + (errmsg("could not find redo location %X/%X referenced by checkpoint record at %X/%X", + LSN_FORMAT_ARGS(checkPoint.redo), LSN_FORMAT_ARGS(CheckPointLoc)), errhint("If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n" "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n" "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup.", @@ -657,7 +658,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, else { ereport(FATAL, - (errmsg("could not locate required checkpoint record"), + (errmsg("could not locate required checkpoint record at %X/%X", + LSN_FORMAT_ARGS(CheckPointLoc)), errhint("If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n" "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n" "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup.", @@ -791,7 +793,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, * simplify processing around checkpoints. */ ereport(PANIC, - (errmsg("could not locate a valid checkpoint record"))); + (errmsg("could not locate a valid checkpoint record at %X/%X", + LSN_FORMAT_ARGS(CheckPointLoc)))); } memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint)); wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN); -- 2.34.1