From d3111cb753e81a64c1a4417ed6de98a90a04432a Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 29 Oct 2025 09:13:31 +0900 Subject: Fix correctness issue with computation of FPI size in WAL stats XLogRecordAssemble() may be called multiple times before inserting a record in XLogInsertRecord(), and the amount of FPIs generated inside a record whose insertion is attempted multiple times may vary. The logic added in f9a09aa29520 touched directly pgWalUsage in XLogRecordAssemble(), meaning that it could be possible for pgWalUsage to be incremented multiple times for a single record. This commit changes the code to use the same logic as the number of FPIs added to a record, where XLogRecordAssemble() returns this information and feeds it to XLogInsertRecord(), updating pgWalUsage only when a record is inserted. Reported-by: Shinya Kato Discussion: https://postgr.es/m/CAOzEurSiSr+rusd0GzVy8Bt30QwLTK=ugVMnF6=5WhsSrukvvw@mail.gmail.com --- src/include/access/xlog.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include') diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index d12798be3d8..a12757e46e5 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -202,6 +202,7 @@ extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata, XLogRecPtr fpw_lsn, uint8 flags, int num_fpi, + uint64 fpi_bytes, bool topxid_included); extern void XLogFlush(XLogRecPtr record); extern bool XLogBackgroundFlush(void); -- cgit v1.2.3