mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Standardize LSN formatting by zero padding
This commit standardizes the output format for LSNs to ensure consistent representation across various tools and messages. Previously, LSNs were inconsistently printed as `%X/%X` in some contexts, while others used zero-padding. This often led to confusion when comparing. To address this, the LSN format is now uniformly set to `%X/%08X`, ensuring the lower 32-bit part is always zero-padded to eight hexadecimal digits. Author: Japin Li <japinli@hotmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://postgr.es/m/ME0P300MB0445CA53CA0E4B8C1879AF84B641A@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
This commit is contained in:
@@ -617,7 +617,7 @@ restart:
|
||||
}
|
||||
else if (targetRecOff < pageHeaderSize)
|
||||
{
|
||||
report_invalid_record(state, "invalid record offset at %X/%X: expected at least %u, got %u",
|
||||
report_invalid_record(state, "invalid record offset at %X/%08X: expected at least %u, got %u",
|
||||
LSN_FORMAT_ARGS(RecPtr),
|
||||
pageHeaderSize, targetRecOff);
|
||||
goto err;
|
||||
@@ -626,7 +626,7 @@ restart:
|
||||
if ((((XLogPageHeader) state->readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD) &&
|
||||
targetRecOff == pageHeaderSize)
|
||||
{
|
||||
report_invalid_record(state, "contrecord is requested by %X/%X",
|
||||
report_invalid_record(state, "contrecord is requested by %X/%08X",
|
||||
LSN_FORMAT_ARGS(RecPtr));
|
||||
goto err;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ restart:
|
||||
if (total_len < SizeOfXLogRecord)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"invalid record length at %X/%X: expected at least %u, got %u",
|
||||
"invalid record length at %X/%08X: expected at least %u, got %u",
|
||||
LSN_FORMAT_ARGS(RecPtr),
|
||||
(uint32) SizeOfXLogRecord, total_len);
|
||||
goto err;
|
||||
@@ -756,7 +756,7 @@ restart:
|
||||
if (!(pageHeader->xlp_info & XLP_FIRST_IS_CONTRECORD))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"there is no contrecord flag at %X/%X",
|
||||
"there is no contrecord flag at %X/%08X",
|
||||
LSN_FORMAT_ARGS(RecPtr));
|
||||
goto err;
|
||||
}
|
||||
@@ -769,7 +769,7 @@ restart:
|
||||
total_len != (pageHeader->xlp_rem_len + gotlen))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"invalid contrecord length %u (expected %lld) at %X/%X",
|
||||
"invalid contrecord length %u (expected %lld) at %X/%08X",
|
||||
pageHeader->xlp_rem_len,
|
||||
((long long) total_len) - gotlen,
|
||||
LSN_FORMAT_ARGS(RecPtr));
|
||||
@@ -1132,7 +1132,7 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr,
|
||||
if (record->xl_tot_len < SizeOfXLogRecord)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"invalid record length at %X/%X: expected at least %u, got %u",
|
||||
"invalid record length at %X/%08X: expected at least %u, got %u",
|
||||
LSN_FORMAT_ARGS(RecPtr),
|
||||
(uint32) SizeOfXLogRecord, record->xl_tot_len);
|
||||
return false;
|
||||
@@ -1140,7 +1140,7 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr,
|
||||
if (!RmgrIdIsValid(record->xl_rmid))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"invalid resource manager ID %u at %X/%X",
|
||||
"invalid resource manager ID %u at %X/%08X",
|
||||
record->xl_rmid, LSN_FORMAT_ARGS(RecPtr));
|
||||
return false;
|
||||
}
|
||||
@@ -1153,7 +1153,7 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr,
|
||||
if (!(record->xl_prev < RecPtr))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"record with incorrect prev-link %X/%X at %X/%X",
|
||||
"record with incorrect prev-link %X/%08X at %X/%08X",
|
||||
LSN_FORMAT_ARGS(record->xl_prev),
|
||||
LSN_FORMAT_ARGS(RecPtr));
|
||||
return false;
|
||||
@@ -1169,7 +1169,7 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr,
|
||||
if (record->xl_prev != PrevRecPtr)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"record with incorrect prev-link %X/%X at %X/%X",
|
||||
"record with incorrect prev-link %X/%08X at %X/%08X",
|
||||
LSN_FORMAT_ARGS(record->xl_prev),
|
||||
LSN_FORMAT_ARGS(RecPtr));
|
||||
return false;
|
||||
@@ -1207,7 +1207,7 @@ ValidXLogRecord(XLogReaderState *state, XLogRecord *record, XLogRecPtr recptr)
|
||||
if (!EQ_CRC32C(record->xl_crc, crc))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"incorrect resource manager data checksum in record at %X/%X",
|
||||
"incorrect resource manager data checksum in record at %X/%08X",
|
||||
LSN_FORMAT_ARGS(recptr));
|
||||
return false;
|
||||
}
|
||||
@@ -1241,7 +1241,7 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr,
|
||||
XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize);
|
||||
|
||||
report_invalid_record(state,
|
||||
"invalid magic number %04X in WAL segment %s, LSN %X/%X, offset %u",
|
||||
"invalid magic number %04X in WAL segment %s, LSN %X/%08X, offset %u",
|
||||
hdr->xlp_magic,
|
||||
fname,
|
||||
LSN_FORMAT_ARGS(recptr),
|
||||
@@ -1256,7 +1256,7 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr,
|
||||
XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize);
|
||||
|
||||
report_invalid_record(state,
|
||||
"invalid info bits %04X in WAL segment %s, LSN %X/%X, offset %u",
|
||||
"invalid info bits %04X in WAL segment %s, LSN %X/%08X, offset %u",
|
||||
hdr->xlp_info,
|
||||
fname,
|
||||
LSN_FORMAT_ARGS(recptr),
|
||||
@@ -1298,7 +1298,7 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr,
|
||||
|
||||
/* hmm, first page of file doesn't have a long header? */
|
||||
report_invalid_record(state,
|
||||
"invalid info bits %04X in WAL segment %s, LSN %X/%X, offset %u",
|
||||
"invalid info bits %04X in WAL segment %s, LSN %X/%08X, offset %u",
|
||||
hdr->xlp_info,
|
||||
fname,
|
||||
LSN_FORMAT_ARGS(recptr),
|
||||
@@ -1318,7 +1318,7 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr,
|
||||
XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize);
|
||||
|
||||
report_invalid_record(state,
|
||||
"unexpected pageaddr %X/%X in WAL segment %s, LSN %X/%X, offset %u",
|
||||
"unexpected pageaddr %X/%08X in WAL segment %s, LSN %X/%08X, offset %u",
|
||||
LSN_FORMAT_ARGS(hdr->xlp_pageaddr),
|
||||
fname,
|
||||
LSN_FORMAT_ARGS(recptr),
|
||||
@@ -1344,7 +1344,7 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr,
|
||||
XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize);
|
||||
|
||||
report_invalid_record(state,
|
||||
"out-of-sequence timeline ID %u (after %u) in WAL segment %s, LSN %X/%X, offset %u",
|
||||
"out-of-sequence timeline ID %u (after %u) in WAL segment %s, LSN %X/%08X, offset %u",
|
||||
hdr->xlp_tli,
|
||||
state->latestPageTLI,
|
||||
fname,
|
||||
@@ -1756,7 +1756,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
if (block_id <= decoded->max_block_id)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"out-of-order block_id %u at %X/%X",
|
||||
"out-of-order block_id %u at %X/%08X",
|
||||
block_id,
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
@@ -1780,14 +1780,14 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
if (blk->has_data && blk->data_len == 0)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"BKPBLOCK_HAS_DATA set, but no data included at %X/%X",
|
||||
"BKPBLOCK_HAS_DATA set, but no data included at %X/%08X",
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
}
|
||||
if (!blk->has_data && blk->data_len != 0)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"BKPBLOCK_HAS_DATA not set, but data length is %u at %X/%X",
|
||||
"BKPBLOCK_HAS_DATA not set, but data length is %u at %X/%08X",
|
||||
(unsigned int) blk->data_len,
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
@@ -1823,7 +1823,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
blk->bimg_len == BLCKSZ))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"BKPIMAGE_HAS_HOLE set, but hole offset %u length %u block image length %u at %X/%X",
|
||||
"BKPIMAGE_HAS_HOLE set, but hole offset %u length %u block image length %u at %X/%08X",
|
||||
(unsigned int) blk->hole_offset,
|
||||
(unsigned int) blk->hole_length,
|
||||
(unsigned int) blk->bimg_len,
|
||||
@@ -1839,7 +1839,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
(blk->hole_offset != 0 || blk->hole_length != 0))
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"BKPIMAGE_HAS_HOLE not set, but hole offset %u length %u at %X/%X",
|
||||
"BKPIMAGE_HAS_HOLE not set, but hole offset %u length %u at %X/%08X",
|
||||
(unsigned int) blk->hole_offset,
|
||||
(unsigned int) blk->hole_length,
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
@@ -1853,7 +1853,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
blk->bimg_len == BLCKSZ)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"BKPIMAGE_COMPRESSED set, but block image length %u at %X/%X",
|
||||
"BKPIMAGE_COMPRESSED set, but block image length %u at %X/%08X",
|
||||
(unsigned int) blk->bimg_len,
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
@@ -1868,7 +1868,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
blk->bimg_len != BLCKSZ)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %u at %X/%X",
|
||||
"neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %u at %X/%08X",
|
||||
(unsigned int) blk->data_len,
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
@@ -1884,7 +1884,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
if (rlocator == NULL)
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"BKPBLOCK_SAME_REL set but no previous rel at %X/%X",
|
||||
"BKPBLOCK_SAME_REL set but no previous rel at %X/%08X",
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
}
|
||||
@@ -1896,7 +1896,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
else
|
||||
{
|
||||
report_invalid_record(state,
|
||||
"invalid block_id %u at %X/%X",
|
||||
"invalid block_id %u at %X/%08X",
|
||||
block_id, LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
goto err;
|
||||
}
|
||||
@@ -1963,7 +1963,7 @@ DecodeXLogRecord(XLogReaderState *state,
|
||||
|
||||
shortdata_err:
|
||||
report_invalid_record(state,
|
||||
"record with invalid length at %X/%X",
|
||||
"record with invalid length at %X/%08X",
|
||||
LSN_FORMAT_ARGS(state->ReadRecPtr));
|
||||
err:
|
||||
*errormsg = state->errormsg_buf;
|
||||
@@ -2073,14 +2073,14 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
|
||||
!record->record->blocks[block_id].in_use)
|
||||
{
|
||||
report_invalid_record(record,
|
||||
"could not restore image at %X/%X with invalid block %d specified",
|
||||
"could not restore image at %X/%08X with invalid block %d specified",
|
||||
LSN_FORMAT_ARGS(record->ReadRecPtr),
|
||||
block_id);
|
||||
return false;
|
||||
}
|
||||
if (!record->record->blocks[block_id].has_image)
|
||||
{
|
||||
report_invalid_record(record, "could not restore image at %X/%X with invalid state, block %d",
|
||||
report_invalid_record(record, "could not restore image at %X/%08X with invalid state, block %d",
|
||||
LSN_FORMAT_ARGS(record->ReadRecPtr),
|
||||
block_id);
|
||||
return false;
|
||||
@@ -2107,7 +2107,7 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
|
||||
bkpb->bimg_len, BLCKSZ - bkpb->hole_length) <= 0)
|
||||
decomp_success = false;
|
||||
#else
|
||||
report_invalid_record(record, "could not restore image at %X/%X compressed with %s not supported by build, block %d",
|
||||
report_invalid_record(record, "could not restore image at %X/%08X compressed with %s not supported by build, block %d",
|
||||
LSN_FORMAT_ARGS(record->ReadRecPtr),
|
||||
"LZ4",
|
||||
block_id);
|
||||
@@ -2124,7 +2124,7 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
|
||||
if (ZSTD_isError(decomp_result))
|
||||
decomp_success = false;
|
||||
#else
|
||||
report_invalid_record(record, "could not restore image at %X/%X compressed with %s not supported by build, block %d",
|
||||
report_invalid_record(record, "could not restore image at %X/%08X compressed with %s not supported by build, block %d",
|
||||
LSN_FORMAT_ARGS(record->ReadRecPtr),
|
||||
"zstd",
|
||||
block_id);
|
||||
@@ -2133,7 +2133,7 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
|
||||
}
|
||||
else
|
||||
{
|
||||
report_invalid_record(record, "could not restore image at %X/%X compressed with unknown method, block %d",
|
||||
report_invalid_record(record, "could not restore image at %X/%08X compressed with unknown method, block %d",
|
||||
LSN_FORMAT_ARGS(record->ReadRecPtr),
|
||||
block_id);
|
||||
return false;
|
||||
@@ -2141,7 +2141,7 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
|
||||
|
||||
if (!decomp_success)
|
||||
{
|
||||
report_invalid_record(record, "could not decompress image at %X/%X, block %d",
|
||||
report_invalid_record(record, "could not decompress image at %X/%08X, block %d",
|
||||
LSN_FORMAT_ARGS(record->ReadRecPtr),
|
||||
block_id);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user