v2-0001-Don-t-hide-xlog-page-header-errors-while-recovery.diff
text/x-patch
Filename: v2-0001-Don-t-hide-xlog-page-header-errors-while-recovery.diff
Type: text/x-patch
Part: 0
Patch
Format: unified
Series: patch v2-0001
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 13 | 1 |
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 24165ab03e..b621ad6b0f 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -12496,9 +12496,21 @@ retry:
*
* Validating the page header is cheap enough that doing it twice
* shouldn't be a big deal from a performance point of view.
+ *
+ * Don't call XLogReaderValidatePageHeader here while not in standby mode
+ * so that this function won't return with a valid errmsg_buf.
*/
- if (!XLogReaderValidatePageHeader(xlogreader, targetPagePtr, readBuf))
+ if (StandbyMode &&
+ !XLogReaderValidatePageHeader(xlogreader, targetPagePtr, readBuf))
{
+ /*
+ * emit this error right now then retry this page immediately
+ * the message is already translated
+ */
+ if (xlogreader->errormsg_buf[0])
+ ereport(emode_for_corrupt_record(emode, EndRecPtr),
+ (errmsg_internal("%s", xlogreader->errormsg_buf)));
+
/* reset any error XLogReaderValidatePageHeader() might have set */
xlogreader->errormsg_buf[0] = '\0';
goto next_record_is_invalid;