Report any XLogReadRecord() error in XlogReadTwoPhaseData().
authorNoah Misch <[email protected]>
Fri, 12 Nov 2021 01:10:18 +0000 (17:10 -0800)
committerNoah Misch <[email protected]>
Fri, 12 Nov 2021 01:11:19 +0000 (17:11 -0800)
Buildfarm members kittiwake and tadarida have witnessed errors at this
site.  The site discarded key facts.  Back-patch to v10 (all supported
versions).

Reviewed by Michael Paquier and Tom Lane.

Discussion: https://postgr.es/m/20211107013157[email protected]

src/backend/access/transam/twophase.c

index 62bf7b4d44f2b10054648d55bf5e62e939a5dcd0..3eb33be69b88f07eecd48ed6dcc64a0e5832dd50 100644 (file)
@@ -1387,11 +1387,21 @@ XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
    ThisTimeLineID = save_currtli;
 
    if (record == NULL)
-       ereport(ERROR,
-               (errcode_for_file_access(),
-                errmsg("could not read two-phase state from WAL at %X/%X",
-                       (uint32) (lsn >> 32),
-                       (uint32) lsn)));
+   {
+       if (errormsg)
+           ereport(ERROR,
+                   (errcode_for_file_access(),
+                    errmsg("could not read two-phase state from WAL at %X/%X: %s",
+                           (uint32) (lsn >> 32),
+                           (uint32) lsn,
+                           errormsg)));
+       else
+           ereport(ERROR,
+                   (errcode_for_file_access(),
+                    errmsg("could not read two-phase state from WAL at %X/%X",
+                           (uint32) (lsn >> 32),
+                           (uint32) lsn)));
+   }
 
    if (XLogRecGetRmid(xlogreader) != RM_XACT_ID ||
        (XLogRecGetInfo(xlogreader) & XLOG_XACT_OPMASK) != XLOG_XACT_PREPARE)