Re: Add wal_fpi_bytes_[un]compressed to pg_stat_wal - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add wal_fpi_bytes_[un]compressed to pg_stat_wal
Date
Msg-id aQC_VKjVuaqnlc-c@paquier.xyz
Whole thread Raw
In response to Re: Add wal_fpi_bytes_[un]compressed to pg_stat_wal  (Shinya Kato <shinya11.kato@gmail.com>)
List pgsql-hackers
On Tue, Oct 28, 2025 at 07:33:00PM +0900, Shinya Kato wrote:
> I investigated previous discussions and found [0]. This thread
> mentioned that XLogInsert() calls XLogRecordAssemble() multiple times
> in its do-while loop, so the value might be invalid.
>
> Based on the discussion above, it seems my previous patch also has the
> same issue.
>
> [0] https://www.postgresql.org/message-id/20200329121944.GA79261%40nol

Dammit, you are right.  I didn't see through this one.  Even on HEAD
it is true that we may trigger an early exit of XLogInsertRecord() and
call XLogRecordAssemble() multiple times with a different FPI setup.
So we cannot do direct manipulations of pgWalUsage in
XLogRecordAssemble(), we must do these once the record is inserted.

I'll clean up that tomorrow, which can be summarized as something like
the attached (quick fix, need to double-check).
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Alexander Kukushkin
Date:
Subject: Re: Issue with logical replication slot during switchover
Next
From: Daniil Davydov
Date:
Subject: Re: POC: Parallel processing of indexes in autovacuum