Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc25ed20

Browse files
committed
Fix record length computation in pg_waldump/xlogdump.
The current method of computing the record length (excluding thelenght of full-page images) has been wrong since the WAL format hasbeen revamped in2c03216. Only themain record's length was counted, but that can be significantly toolittle if there's data associated with further blocks.Fix by computing the record length as total_lenght - fpi_length.Reported-By: Chen HuajunBug: #14687Reviewed-By: Heikki LinnakangasDiscussion:https://postgr.es/m/20170603165939.1436.58887@wrigleys.postgresql.orgBackpatch: 9.5-
1 parent3e60c6f commitc25ed20

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

‎src/bin/pg_waldump/pg_waldump.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -363,37 +363,52 @@ XLogDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen,
363363
}
364364

365365
/*
366-
*Store per-rmgr and per-record statistics for a given record.
366+
*Calculate the size of arecord, split into !FPI and FPI parts.
367367
*/
368368
staticvoid
369-
XLogDumpCountRecord(XLogDumpConfig*config,XLogDumpStats*stats,
370-
XLogReaderState*record)
369+
XLogDumpRecordLen(XLogReaderState*record,uint32*rec_len,uint32*fpi_len)
371370
{
372-
RmgrIdrmid;
373-
uint8recid;
374-
uint32rec_len;
375-
uint32fpi_len;
376371
intblock_id;
377372

378-
stats->count++;
379-
380-
rmid=XLogRecGetRmid(record);
381-
rec_len=XLogRecGetDataLen(record)+SizeOfXLogRecord;
382-
383373
/*
384374
* Calculate the amount of FPI data in the record.
385375
*
386376
* XXX: We peek into xlogreader's private decoded backup blocks for the
387377
* bimg_len indicating the length of FPI data. It doesn't seem worth it to
388378
* add an accessor macro for this.
389379
*/
390-
fpi_len=0;
380+
*fpi_len=0;
391381
for (block_id=0;block_id <=record->max_block_id;block_id++)
392382
{
393383
if (XLogRecHasBlockImage(record,block_id))
394-
fpi_len+=record->blocks[block_id].bimg_len;
384+
*fpi_len+=record->blocks[block_id].bimg_len;
395385
}
396386

387+
/*
388+
* Calculate the length of the record as the total length - the length of
389+
* all the block images.
390+
*/
391+
*rec_len=XLogRecGetTotalLen(record)-*fpi_len;
392+
}
393+
394+
/*
395+
* Store per-rmgr and per-record statistics for a given record.
396+
*/
397+
staticvoid
398+
XLogDumpCountRecord(XLogDumpConfig*config,XLogDumpStats*stats,
399+
XLogReaderState*record)
400+
{
401+
RmgrIdrmid;
402+
uint8recid;
403+
uint32rec_len;
404+
uint32fpi_len;
405+
406+
stats->count++;
407+
408+
rmid=XLogRecGetRmid(record);
409+
410+
XLogDumpRecordLen(record,&rec_len,&fpi_len);
411+
397412
/* Update per-rmgr statistics */
398413

399414
stats->rmgr_stats[rmid].count++;
@@ -422,20 +437,24 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
422437
{
423438
constchar*id;
424439
constRmgrDescData*desc=&RmgrDescTable[XLogRecGetRmid(record)];
440+
uint32rec_len;
441+
uint32fpi_len;
425442
RelFileNodernode;
426443
ForkNumberforknum;
427444
BlockNumberblk;
428445
intblock_id;
429446
uint8info=XLogRecGetInfo(record);
430447
XLogRecPtrxl_prev=XLogRecGetPrev(record);
431448

449+
XLogDumpRecordLen(record,&rec_len,&fpi_len);
450+
432451
id=desc->rm_identify(info);
433452
if (id==NULL)
434453
id=psprintf("UNKNOWN (%x)",info& ~XLR_INFO_MASK);
435454

436455
printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
437456
desc->rm_name,
438-
XLogRecGetDataLen(record),XLogRecGetTotalLen(record),
457+
rec_len,XLogRecGetTotalLen(record),
439458
XLogRecGetXid(record),
440459
(uint32) (record->ReadRecPtr >>32), (uint32)record->ReadRecPtr,
441460
(uint32) (xl_prev >>32), (uint32)xl_prev);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp