Re: Suppressing useless wakeups in walreceiver

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, alvherre(at)alvh(dot)no-ip(dot)org, bharath(dot)rupireddyforpostgres(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Suppressing useless wakeups in walreceiver
Date: 2022-11-14 01:47:14
Message-ID: CA+hUKGKw=+=TZ7xzVRQTNfDy5N_uwW_qWhOHDPHyiAkTQAYUug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 14, 2022 at 1:05 PM Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
> Yeah, I'm able to sort-of reproduce the problem by sending fewer replies,
> but it's not clear to me why that's the problem. AFAICT all of the code
> paths that write/flush are careful to send a reply shortly afterward, which
> should keep writePtr/flushPtr updated.

Ahh, I think I might have it. In the old coding, sendTime starts out
as 0, which I think caused it to send its first reply message after
the first 100ms sleep, and only after that fall into a cadence of
wal_receiver_status_interval (10s) while idle. Our new coding won't
send its first reply until start time + wal_receiver_status_interval.
If I have that right, think we can get back to the previous behaviour
by explicitly setting the first message time, like:

@@ -433,6 +433,9 @@ WalReceiverMain(void)
for (int i = 0; i < NUM_WALRCV_WAKEUPS; ++i)
WalRcvComputeNextWakeup(i, now);

+ /* XXX start with a reply after 100ms */
+ wakeup[WALRCV_WAKEUP_REPLY] = now + 100000;
+
/* Loop until end-of-streaming or error */

Obviously that's bogus and racy (it races with wait_for_catchup, and
it's slow, actually both sides are not great and really should be
event-driven, in later work)...

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2022-11-14 02:25:32 Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment
Previous Message Amit Langote 2022-11-14 01:43:55 Re: Bitmapsets as Nodes