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

Commit 4220e06

Browse files
committed
pg_waldump: Fix bug in per-record statistics.
pg_waldump --stats=record identifies a record by a combination of the RmgrId and the four bits of the xl_info field of the record. But XACT records use the first bit of those four bits for an optional flag variable, and the following three bits for the opcode to identify a record. So previously the same type of XACT record could have different four bits (three bits are the same but the first one bit is different), and which could cause pg_waldump --stats=record to show two lines of per-record statistics for the same XACT record. This is a bug. This commit changes pg_waldump --stats=record so that it processes only XACT record differently, i.e., filters the opcode out of xl_info and uses a combination of the RmgrId and those three bits as the identifier of a record, only for XACT record. For other records, the four bits of the xl_info field are still used. Back-patch to all supported branches. Author: Kyotaro Horiguchi Reviewed-by: Shinya Kato, Fujii Masao Discussion: https://postgr.es/m/2020100913412132258847@highgo.ca
1 parent c0849e4 commit 4220e06

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bin/pg_waldump/pg_waldump.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,15 @@ XLogDumpCountRecord(XLogDumpConfig *config, XLogDumpStats *stats,
509509

510510
recid = XLogRecGetInfo(record) >> 4;
511511

512+
/*
513+
* XACT records need to be handled differently. Those records use the
514+
* first bit of those four bits for an optional flag variable and the
515+
* following three bits for the opcode. We filter opcode out of xl_info
516+
* and use it as the identifier of the record.
517+
*/
518+
if (rmid == RM_XACT_ID)
519+
recid &= 0x07;
520+
512521
stats->record_stats[rmid][recid].count++;
513522
stats->record_stats[rmid][recid].rec_len += rec_len;
514523
stats->record_stats[rmid][recid].fpi_len += fpi_len;

0 commit comments

Comments
 (0)