Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBTqN-0006MY-9P for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 02:42:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBTqK-0004UL-ST for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 02:42:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBTqK-0004UE-LO for pgsql-hackers@lists.postgresql.org; Mon, 15 Feb 2021 02:42:32 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBTqH-0000nO-Vp for pgsql-hackers@postgresql.org; Mon, 15 Feb 2021 02:42:32 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTP id 8FAD562730; Mon, 15 Feb 2021 11:42:25 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 15 Feb 2021 11:42:25 +0900 From: Masahiro Ikeda To: Fujii Masao Cc: PostgreSQL-development , Masahiko Sawada , Li Japin , kuroda.hayato@fujitsu.com, "David G. Johnston" Subject: Re: About to add WAL write/fsync statistics to pg_stat_wal view In-Reply-To: <6d375c1c-57a5-bd0e-f85b-0747b81ffd5d@oss.nttdata.com> References: <0509ad67b585a5b86a83d445dfa75392@oss.nttdata.com> <65e99b78066ab1e3dc82a4e6f5e6f3cd@oss.nttdata.com> <7aef8ee6eea05a38ca91580caa5b2f07@oss.nttdata.com> <8555ab589d74ec2df61237209f4f21f2@oss.nttdata.com> <95c26651303d0e5227cb763061cf15dc@oss.nttdata.com> <395f109540835fabe76dbd9d45733a14@oss.nttdata.com> <925e940a832e96ca5d7276a4cc3dec83@oss.nttdata.com> <3df6e23e3e1e9cd95b08c943ef320046@oss.nttdata.com> <6d375c1c-57a5-bd0e-f85b-0747b81ffd5d@oss.nttdata.com> Message-ID: <4d9a50bcb65e132c11f4a5c44870765b@oss.nttdata.com> X-Sender: ikedamsh@oss.nttdata.com User-Agent: Roundcube Webmail/1.1.9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2021-02-08 14:26, Fujii Masao wrote: > On 2021/02/08 13:01, Fujii Masao wrote: >> >> >> On 2021/02/05 8:45, Masahiro Ikeda wrote: >>> I pgindented the patches. >> >> Thanks for updating the patches! >> >> +       XLogWrite, which nomally called by an >> +       issue_xlog_fsync, which nomally called by >> an >> >> Typo: "nomally" should be "normally"? >> >> +       XLogFlush request(see > linkend="wal-configuration"/>) >> +       XLogFlush request(see > linkend="wal-configuration"/>), >> >> Isn't it better to add a space character just after "request"? >> >> +                    INSTR_TIME_SET_CURRENT(duration); >> +                    INSTR_TIME_SUBTRACT(duration, start); >> +                    WalStats.m_wal_write_time = >> INSTR_TIME_GET_MICROSEC(duration); >> >> If several cycles happen in the do-while loop, m_wal_write_time should >> be >> updated with the sum of "duration" in those cycles instead of >> "duration" >> in the last cycle? If yes, "+=" should be used instead of "=" when >> updating >> m_wal_write_time? >> >> +            INSTR_TIME_SET_CURRENT(duration); >> +            INSTR_TIME_SUBTRACT(duration, start); >> +            WalStats.m_wal_sync_time = >> INSTR_TIME_GET_MICROSEC(duration); >> >> Also "=" should be "+=" in the above? > > + /* Send WAL statistics */ > + pgstat_send_wal(); > > This may cause overhead in WAL-writing by walwriter because it's called > every cycles even when walwriter needs to write more WAL next cycle > (don't need to sleep on WaitLatch)? If this is right, pgstat_send_wal() > should be called only when WaitLatch() returns with WL_TIMEOUT? Thanks, I didn't notice that. I'll fix it. > - XLogFlush request(see linkend="wal-configuration"/>) > + XLogFlush request(see linkend="wal-configuration"/>), > + or WAL data written out to disk by WAL receiver. > > So regarding walreceiver, only wal_write, wal_write_time, wal_sync, and > wal_sync_time are updated even while the other values are not. Isn't > this > confusing to users? If so, what about reporting those walreceiver stats > in > pg_stat_wal_receiver? OK, I'll add new infrastructure code to interect with wal receiver and stats collector and show the stats in pg_stat_wal_receiver. > if (endofwal) > + { > + /* Send WAL statistics to the stats collector */ > + pgstat_send_wal(); > break; > > You added pgstat_send_wal() so that it's called in some cases where > walreceiver exits. But ISTM that there are other walreceiver-exit > cases. > For example, in the case where SIGTERM is received. Instead, > pgstat_send_wal() should be called in WalRcvDie() for those all cases? Thanks, I forgot the case. I'll fix it. Regards, -- Masahiro Ikeda NTT DATA CORPORATION