Improve FATAL message for invalid TLI history at recovery
authorMichael Paquier <[email protected]>
Wed, 26 Feb 2025 05:26:16 +0000 (14:26 +0900)
committerMichael Paquier <[email protected]>
Wed, 26 Feb 2025 05:26:16 +0000 (14:26 +0900)
The original message did not mention where the checkpoint record LSN was
found, a control file or a backup_label file.  A couple of LOG messages
are generated before this FATAL check is reached, providing more details
about the way recovery is set up.  However, knowing this information in
this specific message is useful for debugging.  This is also useful for
instances where log_min_messages is set to FATAL or more, where LOG
messages do not show up.

Author: Benoit LobrĂ©au <[email protected]>
Reviewed-by: David Steele <[email protected]>
Discussion: https://postgr.es/m/4ed10bc8-5513-4d8e-8643-8abcaa08336d@dalibo.com

src/backend/access/transam/xlogrecovery.c

index c5475aaa97a15f22f3e0a2f2e45da42092f36868..52f53fa12e05218fec0605670c16d79ac0186fc6 100644 (file)
@@ -849,7 +849,9 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
        ereport(FATAL,
                (errmsg("requested timeline %u is not a child of this server's history",
                        recoveryTargetTLI),
-                errdetail("Latest checkpoint is at %X/%X on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %X/%X.",
+       /* translator: %s is a backup_label file or a pg_control file */
+                errdetail("Latest checkpoint in file \"%s\" is at %X/%X on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %X/%X.",
+                          haveBackupLabel ? "backup_label" : "pg_control",
                           LSN_FORMAT_ARGS(CheckPointLoc),
                           CheckPointTLI,
                           LSN_FORMAT_ARGS(switchpoint))));