On Thu, Sep 24, 2020 at 03:03:46PM +0900, Michael Paquier wrote: > Hmm. I still think that knowing at least about a FPW could be an > interesting piece of information even here. Anyway, instead of > copying a logic that exists already in xlog_outrec(), why not moving > the block information print into a separate routine out of the > WAL_DEBUG section, and just reuse the same format for the context of > the redo error callback? That would also be more consistent with what > we do in pg_waldump where we don't show the fork name of a block when > it is on a MAIN_FORKNUM. And this would avoid a third copy of the > same logic. If we add the XID, previous LSN and the record length > on the stack of what is printed, we could just reuse the existing > routine, still that's perhaps too much information displayed.
Seeing nothing, I took a swing at that, and finished with the attached that refactors the logic and prints the block information as wanted. Any objections to that? -- Michael
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 79a77ebbfe..e96075158a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -940,6 +940,7 @@ static bool CheckForStandbyTrigger(void);
#ifdef WAL_DEBUG
static void xlog_outrec(StringInfo buf, XLogReaderState *record);
#endif
+static void xlog_block_info(StringInfo buf, XLogReaderState *record);
static void xlog_outdesc(StringInfo buf, XLogReaderState *record);
static void pg_start_backup_callback(int code, Datum arg);
static void pg_stop_backup_callback(int code, Datum arg);
@@ -10258,6 +10259,19 @@ xlog_outrec(StringInfo buf, XLogReaderState *record)
appendStringInfo(buf, "; len %u",
XLogRecGetDataLen(record));
+ xlog_block_info(buf, record);
+}
+#endif /* WAL_DEBUG */
+
+/*
+ * Returns a string giving information about all the blocks in an
+ * XLogRecord.
+ */
+static void
+xlog_block_info(StringInfo buf, XLogReaderState *record)
+{
+ int block_id;
+
/* decode block references */
for (block_id = 0; block_id <= record->max_block_id; block_id++)
{
@@ -10284,7 +10298,6 @@ xlog_outrec(StringInfo buf, XLogReaderState *record)
appendStringInfoString(buf, " FPW");
}
}
-#endif /* WAL_DEBUG */
/*
* Returns a string describing an XLogRecord, consisting of its identity
@@ -11765,6 +11778,7 @@ rm_redo_error_callback(void *arg)
initStringInfo(&buf);
xlog_outdesc(&buf, record);
+ xlog_block_info(&buf, record);
/* translator: %s is a WAL record description */
errcontext("WAL redo at %X/%X for %s",
signature.asc
Description: PGP signature
