Re: wal stats questions

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: masao(dot)fujii(at)oss(dot)nttdata(dot)com
Cc: andres(at)anarazel(dot)de, ikedamsh(at)oss(dot)nttdata(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: wal stats questions
Date: 2021-03-26 01:08:28
Message-ID: 20210326.100828.1578001749705763697.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 25 Mar 2021 19:01:23 +0900, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote in
> On 2021/03/25 16:37, Kyotaro Horiguchi wrote:
> > pgWalUsage was used without resetting and we (I) thought that that
> > behavior should be preserved. On second thought, as Andres suggested,
> > we can just reset pgWalUsage at sending since AFAICS no one takes
> > difference crossing pgstat_report_stat() calls.
>
> Yes, I agree that we can do that since there seems no such code for
> now.
> Also if we do that, we can check, for example "pgWalUsage.wal_records
> > 0"
> as you suggested, to easily determine whether there is pending WAL
> stats or not.
> Anyway I agree it's better to add comments about the design more.
...
> > If any wal activity has been recorded, wal_records is always positive
> > thus we can check for wal activity just by "pgWalUsage.wal_records >
> > 0, which should be fast enough.
>
> Maybe there is the case where a backend generates no WAL records,
> but just writes them because it needs to do write-ahead-logging
> when flush the table data? If yes, "pgWalUsage.wal_records > 0" is not
> enough.
> Probably other fields also need to be checked.

(I noticed I made the discussion above unconsciously premising
pgWalUsage reset.)

I may be misunderstanding or missing something, but the only place
where pgWalUsage counters are increased is XLogInsertRecrod. That is,
pgWalUsage counts wal insertions, not writes nor flushes. AFAICS
pgWalUsage.wal_records is always incremented when other counters are
increased. Looking from another side, we should refrain from adding
counters that incrases at a different time than
pgWalUsage.wal_recrods. (That should be written as a comment there.)

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2021-03-26 01:23:38 Re: Stronger safeguard for archive recovery not to miss data
Previous Message Fujii Masao 2021-03-26 00:54:40 Re: make the stats collector shutdown without writing the statsfiles if the immediate shutdown is requested.