aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2021-03-23 09:53:08 +0900
committerFujii Masao <fujii@postgresql.org>2021-03-23 09:53:08 +0900
commit51893c8463501fc9a38e39cc097773dbdfb9db82 (patch)
tree8a16145cd43be7b78e7a87fa90cb60c729fb66c8 /src
parent95d77149c53545a74e0c84717cf8f925b8f6d632 (diff)
downloadpostgresql-51893c8463501fc9a38e39cc097773dbdfb9db82.tar.gz
postgresql-51893c8463501fc9a38e39cc097773dbdfb9db82.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_waldump/pg_waldump.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 610f65e471c..f8b8afe4a7b 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -438,6 +438,15 @@ XLogDumpCountRecord(XLogDumpConfig *config, XLogDumpStats *stats,
recid = XLogRecGetInfo(record) >> 4;
+ /*
+ * XACT records need to be handled differently. Those records use the
+ * first bit of those four bits for an optional flag variable and the
+ * following three bits for the opcode. We filter opcode out of xl_info
+ * and use it as the identifier of the record.
+ */
+ if (rmid == RM_XACT_ID)
+ recid &= 0x07;
+
stats->record_stats[rmid][recid].count++;
stats->record_stats[rmid][recid].rec_len += rec_len;
stats->record_stats[rmid][recid].fpi_len += fpi_len;