Hi,
pgstat_report_wal() calls pgstat_flush_wal() and pgstat_flush_io(). When
calling them, pgstat_report_wal() specifies its argument "force" as the
argument of them, as follows. But according to the code of
pgstat_flush_wal() and pgstat_flush_io(), their argument is "nowait" and
its meaning seems the opposite of "force". This means that, even when
checkpointer etc calls pgstat_report_wal() with force=true to forcibly
flush the statistics, pgstat_flush_wal() and pgstat_flush_io() skip
flushing the statistics if they fail to acquire the lock immediately
because they are called with nowait=true. This seems unexpected behavior
and a bug.
void
pgstat_report_wal(bool force)
{
pgstat_flush_wal(force);
pgstat_flush_io(force);
}
BTW, pgstat_report_stat() treats "nowait" and "force" as the opposite
one, as follows.
/* don't wait for lock acquisition when !force */
nowait = !force;
Ryoga Yoshida
diff --git a/src/backend/utils/activity/pgstat_wal.c b/src/backend/utils/activity/pgstat_wal.c
index bcaed14d02..f9b5ee8a7b 100644
--- a/src/backend/utils/activity/pgstat_wal.c
+++ b/src/backend/utils/activity/pgstat_wal.c
@@ -42,9 +42,9 @@ static WalUsage prevWalUsage;
void
pgstat_report_wal(bool force)
{
- pgstat_flush_wal(force);
+ pgstat_flush_wal(!force);
- pgstat_flush_io(force);
+ pgstat_flush_io(!force);
}
/*