pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
3+ messages / 2 participants
[nested] [flat]
* pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
@ 2020-04-11 17:35 Noah Misch <noah@leadboat.com>
0 siblings, 1 reply; 3+ messages in thread
From: Noah Misch @ 2020-04-11 17:35 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
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.
Discussion: https://postgr.es/m/20200406063649.GA3738151@rfd.leadboat.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/421685812290406daea58b78dfab0346eb683bbb
Modified Files
--------------
src/backend/replication/walsender.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
@ 2020-04-16 19:50 Fujii Masao <masao.fujii@oss.nttdata.com>
parent: Noah Misch <noah@leadboat.com>
0 siblings, 1 reply; 3+ messages in thread
From: Fujii Masao @ 2020-04-16 19:50 UTC (permalink / raw)
To: Noah Misch <noah@leadboat.com>; pgsql-committers@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
@ 2020-04-17 05:44 Noah Misch <noah@leadboat.com>
parent: Fujii Masao <masao.fujii@oss.nttdata.com>
0 siblings, 0 replies; 3+ messages in thread
From: Noah Misch @ 2020-04-17 05:44 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@oss.nttdata.com>; +Cc: pgsql-committers@lists.postgresql.org
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-04-17 05:44 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 17:35 pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal(). Noah Misch <noah@leadboat.com>
2020-04-16 19:50 ` Fujii Masao <masao.fujii@oss.nttdata.com>
2020-04-17 05:44 ` Noah Misch <noah@leadboat.com>
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