Re: Lost walsender wakeup stalls synchronous commits until the standby's next reply (16+)

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Alex Speller <alex(at)alexspeller(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Lost walsender wakeup stalls synchronous commits until the standby's next reply (16+)
Date: 2026-11-25 09:13:57
Message-ID: CABPTF7ViXw4yPq9hJaM1UqPbH9GJSeRYeT1k_11Bx5iGQvAn4Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Nov 25, 2026 at 3:47 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Thu, Nov 12, 2026 at 8:35 PM Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
> > Thanks for the patch! v1 looks correct for WalSenderWaitForWal.
>
> Thanks for the review! I've pushed the patch.
>
>
> > It seems that WaitForStandbyConfirmation (17+) has the same race: a
> > standby can confirm between NeedToWaitForStandbys() and joining
> > wal_confirm_rcv_cv. Later replies would not wake it until restart_lsn
> > advances, which could stall synchronous commits too.
> >
> > The attached reproducer adds a 3s delay before joining the waitlist,
> > and resumes the standby during that delay. With wal_sender_timeout = 0
> > and pg_recvlogical -s 0, the sender stalls for about 10s, its idle
> > timeout, even if the standby has caught up.
> >
> > If this is an issue, do we need to apply the recheck like
> > StandbySlotsHaveCaughtup() before registration as well?
>
> Thanks for reporting this issue!
>
> Yeah, Codex also identified it when I used it to review the patch for
> logical replication. I was thinking to look into it after fixing the logical
> replication issue. Now that I've pushed that fix, I'll work on this one next.

Thanks for dealing with it. I'll look at it while it's ready.

BTW, for the long term, on HEAD, I've been thinking & working on
moving some parts of the walsenders' WAL waits from condition
variables to the xlogwait infra (Heikki also suggested this in a prior
email). I think that could avoid this type of lost wakeup and have
some additional benefits. But it has a few things to consider. I'll
bring it to the mailing list while it's in a reasonable shape.

--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Álvaro Herrera 2026-11-25 09:43:15 Re: BUG #19932: `repack (concurrently)` does not work in `psql` with `AUTOCOMMIT` set to `off`
Previous Message Kyotaro Horiguchi 2026-11-25 08:30:06 Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"