Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: When WalSndCaughtUp, sleep only in WalSndWaitForWal().
Date: 2020-04-16 19:50:38
Message-ID: 3e370b08-96a2-fe03-421e-9a188cb66cce@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2020-04-16 22:30:25 pgsql: Remove unneeded constraint dependency tracking
Previous Message Tom Lane 2020-04-16 18:46:19 pgsql: Fix cache reference leak in contrib/sepgsql.