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 1l8z43-0001Lh-3G for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Feb 2021 05:26:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l8z41-0005US-O3 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Feb 2021 05:26:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8z41-0005UK-H0 for pgsql-hackers@lists.postgresql.org; Mon, 08 Feb 2021 05:26:21 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8z3w-0007vf-Um for pgsql-hackers@postgresql.org; Mon, 08 Feb 2021 05:26:19 +0000 Received: from hnk.local (p2112118-ipbf2507funabasi.chiba.ocn.ne.jp [123.216.63.118]) by oss.nttdata.com (Postfix) with ESMTPSA id 00FDE627A8; Mon, 8 Feb 2021 14:26:14 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: About to add WAL write/fsync statistics to pg_stat_wal view From: Fujii Masao To: Masahiro Ikeda , PostgreSQL-development Cc: Masahiko Sawada , Li Japin , kuroda.hayato@fujitsu.com, "David G. Johnston" 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> Message-ID: <6d375c1c-57a5-bd0e-f85b-0747b81ffd5d@oss.nttdata.com> Date: Mon, 8 Feb 2021 14:26:14 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 ) > +       XLogFlush request(see ), > > 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? - XLogFlush request(see ) + XLogFlush request(see ), + 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? 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? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION