Re: [PG19] Promotion hangs behind a backend blocked on a stuck client

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Manu <manuelreyesbravo(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>
Subject: Re: [PG19] Promotion hangs behind a backend blocked on a stuck client
Date: 2026-10-17 00:27:17
Message-ID: CAD21AoB2OPsR8L1f5TE+W+p8Ayy1eb8w6K1b3sJr2RCGFp5bPA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 15, 2026 at 8:27 PM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Hi,
>
> Hayato, you are right, thanks. v4-0001 sets the latch again if a
> barrier is still pending, as Manu suggested. With your change on top,
> DROP DATABASE waited 60 seconds with v2-0001 and 15 ms with v4-0001.
>
> Manu, I took all of your test changes. On 19 and master the test fails
> without 0001 and passes with it.

I agree that 0001 is what fixes the rest. I'm reviewing it now, but
what I'm unsure about is whether to include it in v19 at this point.
It creates a new place where barrier callbacks run in the middle of a
protocol message, with any ERROR upgraded to FATAL, and every barrier
type we add later will have to be safe there. Neither of the two types
in v19 throws today, so this is more about what could break there
later, but it's the kind of change I'd want more time on than RC gives
us.

From the numbers upthread, a backend blocked writing to the client
(for example COPY TO STDOUT, or taking a base backup) looks like the
only case that is both likely and unbounded; the others either release
themselves or can't happen on a standby. It also needs a consumer that
has stopped rather than one that is just slow.

There are workarounds in the meantime. Setting wal_level=logical on
the standby skips the barrier entirely thanks to the recent commit. If
it does happen, the startup process logs the holding PID every five
seconds, and pg_terminate_backend() on that PID lets the promotion
finish.

So I'm currently leaning towards master only and we live with the
restriction in v19. Feedback is very welcome.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Donghang Lin 2026-10-17 00:47:02 Re: Fix stale allocChunkLimit when recycling AllocSet
Previous Message Haibo Yan 2026-10-17 00:12:14 Re: Reducing relcache memory usage 2: shrink sizeof(RelationData)