pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ryoga Yoshida <bt23yoshidar@oss.nttdata.com>
To: pgsql-hackers@lists.postgresql.org
Subject: Doesn't pgstat_report_wal() handle the argument "force" incorrectly
Date: Fri, 22 Sep 2023 13:58:37 +0900
Message-ID: <f87a4d7be70530606b864fd1df91718c@oss.nttdata.com> (raw)

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





view thread (9+ messages)  latest in thread

Message-ID: <f87a4d7be70530606b864fd1df91718c@oss.nttdata.com>
Permalink:  ../f87a4d7be70530606b864fd1df91718c@oss.nttdata.com/
Also on:    postgresql.org/message-id/f87a4d7be70530606b864fd1df91718c@oss.nttdata.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: bt23yoshidar@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Doesn't pgstat_report_wal() handle the argument "force" incorrectly
  In-Reply-To: <f87a4d7be70530606b864fd1df91718c@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox