From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Li Japin <japinli@hotmail.com>
Cc: kuroda.hayato@fujitsu.com
Subject: Re: About to add WAL write/fsync statistics to pg_stat_wal view
Date: Fri, 19 Mar 2021 16:30:04 +0900
Message-ID: <ce0f7bf6-9c7d-0a80-c580-3952c49d87e1@oss.nttdata.com> (raw)
In-Reply-To: <90d8baf25655a08299185cb1a616bda1@oss.nttdata.com>
References: <0509ad67b585a5b86a83d445dfa75392@oss.nttdata.com>
<CAKFQuwYHX-h3_LkrbNYUguN9fP-YfOVsKyVJ8EaZY2O4Z0upGA@mail.gmail.com>
<23a9f71817f616135551e2fde5ef362e@oss.nttdata.com>
<a7c255be-ca6e-b31f-b836-74eccf9510a8@oss.nttdata.com>
<930cae989a0fe8db6870cbeb5f24cf97@oss.nttdata.com>
<9a70efda-6f47-8b1c-0513-419e1185000a@oss.nttdata.com>
<6c8932c2b0756971e4b28f06af07be9a@oss.nttdata.com>
<4a81fc95615db54b75f59759752b2cef@oss.nttdata.com>
<49d412cc-2e39-a487-1861-a8560ebb88cb@oss.nttdata.com>
<da0059e5e7282573c52ecffd3554a810@oss.nttdata.com>
<b10edd92-b428-25e9-89d4-e36592a67363@oss.nttdata.com>
<99fbf195e4b02a629cbf8190a0b9d47a@oss.nttdata.com>
<7c08820c-06d6-0968-100a-5df71d67768b@oss.nttdata.com>
<f2ea17310b046cc6688b6f868a780cc8@oss.nttdata.com>
<550de3c1-3408-de76-6fc1-a46eedc217a3@oss.nttdata.com>
<b53fc36fbc55fe6c08d4fa0df0d29a5b@oss.nttdata.com>
<a965d3ed-47d3-7d30-c15f-fc0f98810e4d@oss.nttdata.com>
<90d8baf25655a08299185cb1a616bda1@oss.nttdata.com>
On 2021/03/15 10:39, Masahiro Ikeda wrote:
> Thanks, I understood get_sync_bit() checks the sync flags and
> the write unit of generated wal data and replicated wal data is different.
> (It's interesting optimization whether to use kernel cache or not.)
>
> OK. Although I agree to separate the stats for the walrecever,
> I want to hear opinions from other people too. I didn't change the patch.
>
> Please feel to your comments.
What about applying the patch for common WAL write function like
XLogWriteFile(), separately from the patch for walreceiver's stats?
Seems the former reaches the consensus, so we can commit it firstly.
Also even only the former change is useful because which allows
walreceiver to report WALWrite wait event.
> OK. I agree.
>
> I wonder to change the error check ways depending on who calls this function?
> Now, only the walreceiver checks (1)errno==0 and doesn't check (2)errno==ENITR.
> Other processes are the opposite.
>
> IIUC, it's appropriate that every process checks (1)(2).
> Please let me know my understanding is wrong.
I'm thinking the same. Regarding (2), commit 79ce29c734 introduced
that code. According to the following commit log, it seems harmless
to retry on EINTR even walreceiver.
Also retry on EINTR. All signals used in the backend are flagged SA_RESTART
nowadays, so it shouldn't happen, but better to be defensive.
>> BTW, currently XLogWrite() increments IO timing even when pg_pwrite()
>> reports an error. But this is useless. Probably IO timing should be
>> incremented after the return code of pg_pwrite() is checked, instead?
>
> Yes, I agree. I fixed it.
> (v18-0003-Makes-the-wal-receiver-report-WAL-statistics.patch)
Thanks for the patch!
nleft = nbytes;
do
{
- errno = 0;
+ written = XLogWriteFile(openLogFile, from, nleft, (off_t) startoffset,
+ ThisTimeLineID, openLogSegNo, wal_segment_size);
Can we merge this do-while loop in XLogWrite() into the loop
in XLogWriteFile()?
If we do that, ISTM that the following codes are not necessary in XLogWrite().
nleft -= written;
from += written;
+ * 'segsize' is a segment size of WAL segment file.
Since segsize is always wal_segment_size, segsize argument seems
not necessary in XLogWriteFile().
+XLogWriteFile(int fd, const void *buf, size_t nbyte, off_t offset,
+ TimeLineID timelineid, XLogSegNo segno, int segsize)
Why did you use "const void *" instead of "char *" for *buf?
Regarding 0005 patch, I will review it later.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: masao.fujii@oss.nttdata.com, ikedamsh@oss.nttdata.com, david.g.johnston@gmail.com, sawada.mshk@gmail.com, japinli@hotmail.com, kuroda.hayato@fujitsu.com
Subject: Re: About to add WAL write/fsync statistics to pg_stat_wal view
In-Reply-To: <ce0f7bf6-9c7d-0a80-c580-3952c49d87e1@oss.nttdata.com>
References: <0509ad67b585a5b86a83d445dfa75392@oss.nttdata.com> <23a9f71817f616135551e2fde5ef362e@oss.nttdata.com> <a7c255be-ca6e-b31f-b836-74eccf9510a8@oss.nttdata.com> <930cae989a0fe8db6870cbeb5f24cf97@oss.nttdata.com> <9a70efda-6f47-8b1c-0513-419e1185000a@oss.nttdata.com> <6c8932c2b0756971e4b28f06af07be9a@oss.nttdata.com> <4a81fc95615db54b75f59759752b2cef@oss.nttdata.com> <49d412cc-2e39-a487-1861-a8560ebb88cb@oss.nttdata.com> <da0059e5e7282573c52ecffd3554a810@oss.nttdata.com> <b10edd92-b428-25e9-89d4-e36592a67363@oss.nttdata.com> <99fbf195e4b02a629cbf8190a0b9d47a@oss.nttdata.com> <7c08820c-06d6-0968-100a-5df71d67768b@oss.nttdata.com> <f2ea17310b046cc6688b6f868a780cc8@oss.nttdata.com> <550de3c1-3408-de76-6fc1-a46eedc217a3@oss.nttdata.com> <b53fc36fbc55fe6c08d4fa0df0d29a5b@oss.nttdata.com> <a965d3ed-47d3-7d30-c15f-fc0f98810e4d@oss.nttdata.com> <90d8baf25655a08299185cb1a616bda1@oss.nttdata.com> <ce0f7bf6-9c7d-0a80-c580-3952c49d87e1@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