Doesn't pgstat_report_wal() handle the argument "force" incorrectly

From: Ryoga Yoshida <bt23yoshidar(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Doesn't pgstat_report_wal() handle the argument "force" incorrectly
Date: 2023-09-22 05:11:14
Message-ID: f02b13cc9ca7909d7091852dd9c94a9e@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v1-0001-bug-fix-in-foce-within-pgstat_report_wal.patch text/x-diff 430 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2023-09-22 05:16:40 Re: Row pattern recognition
Previous Message Ryoga Yoshida 2023-09-22 04:58:37 Doesn't pgstat_report_wal() handle the argument "force" incorrectly