pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid unnecessary end-of-recovery barrier waits
Date: Fri, 16 Oct 2026 15:15:21 +0000
Message-ID: <E1xHjeT-00000001tdT-3WjA@gemulon.postgresql.org> (raw)

Avoid unnecessary end-of-recovery barrier waits

Commit 67c20979ce7 made end-of-recovery processing emit a process signal
barrier and wait for all processes to refresh their cached logical WAL
logging state. This can hold up promotion indefinitely if a backend
cannot process the barrier, for example while blocked sending data to
a client that has stopped reading.

At wal_level=logical, logical WAL logging is enabled regardless of the
cached state, so no cache synchronization is needed. Skip emitting and
waiting for the barrier in this case.

When logical decoding will be disabled after recovery, stale caches
can only cause extra logical information to be written to WAL, which is
safe. Still emit the barrier so processes update their caches
asynchronously, but no longer wait for it to complete.

These changes allow promotion to finish without waiting for unresponsive
backends to process this barrier in either case. Retain the wait in
other cases, even if the shared state has not changed, to prevent
processes with stale caches from omitting required logical information
after recovery.

Reported-by: shihao zhong <zhong950419@gmail.com>
Author: Fujii Masao <masao.fujii@gmail.com>
Author: Manuel Reyes Bravo <manuelreyesbravo@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqToBk9c2sPAgha-kCgxJhVwn90j1sCyUXrvydq51LKAqA@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/df1be4ddc8345235ffc736adc7dc954f0f944daa

Modified Files
--------------
src/backend/replication/logical/logicalctl.c | 33 ++++++++++++++++++----------
1 file changed, 21 insertions(+), 12 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1xHjeT-00000001tdT-3WjA@gemulon.postgresql.org>
Permalink:  ../E1xHjeT-00000001tdT-3WjA@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xHjeT-00000001tdT-3WjA@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org
  Subject: Re: pgsql: Avoid unnecessary end-of-recovery barrier waits
  In-Reply-To: <E1xHjeT-00000001tdT-3WjA@gemulon.postgresql.org>
  References: <E1xHjeT-00000001tdT-3WjA@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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