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 1jPAXK-0004pL-GM for pgsql-committers@arkaria.postgresql.org; Thu, 16 Apr 2020 19:50:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jPAXI-0007TY-7i for pgsql-committers@arkaria.postgresql.org; Thu, 16 Apr 2020 19:50:56 +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 1jPAXI-0007PI-1r for pgsql-committers@lists.postgresql.org; Thu, 16 Apr 2020 19:50:56 +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 1jPAX7-0001Jh-M4 for pgsql-committers@lists.postgresql.org; Thu, 16 Apr 2020 19:50:54 +0000 Received: from hnk.local (p2421237-ipbf2725funabasi.chiba.ocn.ne.jp [122.24.33.237]) by oss.nttdata.com (Postfix) with ESMTPSA id 5310B601A2; Fri, 17 Apr 2020 04:50:39 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at oss.nttdata.com Subject: Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal(). To: Noah Misch , pgsql-committers@lists.postgresql.org References: From: Fujii Masao Message-ID: <3e370b08-96a2-fe03-421e-9a188cb66cce@oss.nttdata.com> Date: Fri, 17 Apr 2020 04:50:38 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/04/12 2:35, Noah Misch wrote: > When WalSndCaughtUp, sleep only in WalSndWaitForWal(). > > Before sleeping, WalSndWaitForWal() sends a keepalive if MyWalSnd->write > < sentPtr. That is important in logical replication. When the latest > physical LSN yields no logical replication messages (a common case), > that keepalive elicits a reply, and processing the reply updates > pg_stat_replication.replay_lsn. WalSndLoop() lacks that; when > WalSndLoop() slept, replay_lsn advancement could stall until > wal_receiver_status_interval elapsed. This sometimes stalled > src/test/subscription/t/001_rep_changes.pl for up to 10s. Since this commit, walsender started consuming CPU resource too much in my env. wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT | - WL_SOCKET_READABLE; + WL_SOCKET_READABLE | WL_SOCKET_WRITEABLE; I wonder if this change caused WaitLatchOrSocket() in WalSndLoop() to wake up frequently more than necessary. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION