On Mon, Sep 25, 2023 at 11:27:27AM +0900, Ryoga Yoshida wrote: > Thank you for the review. Certainly, adding a comments is a good idea. I > added a comment.
Hmm. How about the attached version with some tweaks? -- Michael
diff --git a/src/backend/utils/activity/pgstat_wal.c b/src/backend/utils/activity/pgstat_wal.c index bcaed14d02..82feb792cf 100644 --- a/src/backend/utils/activity/pgstat_wal.c +++ b/src/backend/utils/activity/pgstat_wal.c @@ -38,13 +38,18 @@ static WalUsage prevWalUsage; * * Must be called by processes that generate WAL, that do not call * pgstat_report_stat(), like walwriter. + * + * force set to true ensures that the statistics are flushed; note that + * this needs to acquire the pgstat shmem LWLock, waiting on it. When + * set to false, the statistics may not be flushed if the lock could not + * be acquired. */ void pgstat_report_wal(bool force) { - pgstat_flush_wal(force); - - pgstat_flush_io(force); + /* like in pgstat.c, don't wait for lock acquisition when !force */ + pgstat_flush_wal(!force); + pgstat_flush_io(!force); } /*
signature.asc
Description: PGP signature