Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9d0bd95

Browse files
committed
Add block information in error context of WAL REDO apply loop
Providing this information can be useful for example when diagnosing problems related to recovery conflicts or for recovery issues without having to go through the output generated by pg_waldump to get some information about the blocks a WAL record works on. The block information is printed in the same format as pg_waldump. This already existed in xlog.c for debugging purposes with -DWAL_DEBUG, so adding the block information in the callback has required just a small refactoring. Author: Bertrand Drouvot Reviewed-by: Michael Paquier, Masahiko Sawada Discussion: https://postgr.es/m/c31e2cba-efda-762c-f4ad-5c25e5dac3d0@amazon.com
1 parent 4964253 commit 9d0bd95

File tree

1 file changed

+15
-1
lines changed
  • src/backend/access/transam

1 file changed

+15
-1
lines changed

src/backend/access/transam/xlog.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ static bool CheckForStandbyTrigger(void);
940940
#ifdef WAL_DEBUG
941941
static void xlog_outrec(StringInfo buf, XLogReaderState *record);
942942
#endif
943+
static void xlog_block_info(StringInfo buf, XLogReaderState *record);
943944
static void xlog_outdesc(StringInfo buf, XLogReaderState *record);
944945
static void pg_start_backup_callback(int code, Datum arg);
945946
static void pg_stop_backup_callback(int code, Datum arg);
@@ -10258,6 +10259,19 @@ xlog_outrec(StringInfo buf, XLogReaderState *record)
1025810259
appendStringInfo(buf, "; len %u",
1025910260
XLogRecGetDataLen(record));
1026010261

10262+
xlog_block_info(buf, record);
10263+
}
10264+
#endif /* WAL_DEBUG */
10265+
10266+
/*
10267+
* Returns a string giving information about all the blocks in an
10268+
* XLogRecord.
10269+
*/
10270+
static void
10271+
xlog_block_info(StringInfo buf, XLogReaderState *record)
10272+
{
10273+
int block_id;
10274+
1026110275
/* decode block references */
1026210276
for (block_id = 0; block_id <= record->max_block_id; block_id++)
1026310277
{
@@ -10284,7 +10298,6 @@ xlog_outrec(StringInfo buf, XLogReaderState *record)
1028410298
appendStringInfoString(buf, " FPW");
1028510299
}
1028610300
}
10287-
#endif /* WAL_DEBUG */
1028810301

1028910302
/*
1029010303
* Returns a string describing an XLogRecord, consisting of its identity
@@ -11765,6 +11778,7 @@ rm_redo_error_callback(void *arg)
1176511778

1176611779
initStringInfo(&buf);
1176711780
xlog_outdesc(&buf, record);
11781+
xlog_block_info(&buf, record);
1176811782

1176911783
/* translator: %s is a WAL record description */
1177011784
errcontext("WAL redo at %X/%X for %s",

0 commit comments

Comments
 (0)