From: Noah Misch <noah@leadboat.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
Date: Thu, 16 Apr 2020 22:44:12 -0700
Message-ID: <20200417054412.GB1061007@rfd.leadboat.com> (raw)
In-Reply-To: <3e370b08-96a2-fe03-421e-9a188cb66cce@oss.nttdata.com>
References: <E1jNK2f-0000Vx-Fr@gemulon.postgresql.org>
<3e370b08-96a2-fe03-421e-9a188cb66cce@oss.nttdata.com>
On Fri, Apr 17, 2020 at 04:50:38AM +0900, Fujii Masao wrote:
> 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.
Confirmed. I have shared this with the main thread and added details there.
> 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.
I collected lower wakeup counts after the commit. The problem is a shortage
of waits.
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-committers@postgresql.org
Cc: noah@leadboat.com, masao.fujii@oss.nttdata.com
Subject: Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
In-Reply-To: <20200417054412.GB1061007@rfd.leadboat.com>
References: <E1jNK2f-0000Vx-Fr@gemulon.postgresql.org> <3e370b08-96a2-fe03-421e-9a188cb66cce@oss.nttdata.com> <20200417054412.GB1061007@rfd.leadboat.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