public inbox for [email protected]  
help / color / mirror / Atom feed
From: Mateusz Kosek <[email protected]>
To: [email protected]
Subject: BUG??/FEATURE REQUEST: Streaming replication walreceiver doesn't restart after standby reboot with recovery_min_apply_delay
Date: Fri, 3 Apr 2026 23:35:42 +0200
Message-ID: <CAFyWK5f6r51vGL-YroYQczcwY4zTryCoW_NdAVn=LMSMmCEbrw@mail.gmail.com> (raw)

--0000000000008b5158064e951bad
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

I'm setting up a standby replica that replicates data from the primary in
real-time, but replays WAL logs with a 7-day delay using
recovery_min_apply_delay =3D '7d'.
The goal is to handle two scenarios:
1. Primary failure: promote the standby (which was streaming continuously)
with minimal recent transaction loss.
2. Accidental data loss (e.g., DROP TABLE, bad DELETE/UPDATE): recover from
the delayed replay within 7 days.

Standby config:
OS: Debian 13.4
PG: 18.1 (built from source)

Base backup:
pg_basebackup -h 10.88.0.12 -p 5432 -D /var/lib/postgresql/18.1/test -U
test_replication --create-slot --slot=3Dtest_slot --checkpoint=3Dfast
--progress --wal-method=3Dstream --write-recovery-conf

Added to postgresql.conf:
hot_standby =3D on
recovery_min_apply_delay =3D '7d'

Confirmed postgresql.auto.conf has:
primary_conninfo
primary_slot_name

Initial behavior works fine:
walreceiver starts:
ps awux | grep wal
postgres  988251  0.1  0.0 285464  8952 ?        Ss   00:00   2:31
postgres: walreceiver streaming 3CC/EFC17820

replay_delay grows as expected:
postgres=3D# SELECT
  pg_last_wal_receive_lsn() AS received_lsn,
  pg_last_wal_replay_lsn() AS replayed_lsn,
  pg_last_xact_replay_timestamp() AS replay_timestamp,
  now() - pg_last_xact_replay_timestamp() AS replay_delay;
 received_lsn | replayed_lsn |           replay_timestamp           |
 replay_delay
--------------+--------------+--------------------------------------+------=
-----------
 3CC/EFC28A58 | 3C7/BF8A4CD8 | Fri 03 Apr 00:00:07.278303 2026 CEST |
22:19:24.777788

Standby pg_wal is growing (expected due to delay):
du -h 18.1/test/pg_wal/
4.0K    18.1/test/pg_wal/summaries
988K    18.1/test/pg_wal/archive_status
21G     18.1/test/pg_wal/

Primary stays clean:
du -sch 18.1/main/pg_wal/
33M     18.1/main/pg_wal/
33M     total

Problem after standby reboot (e.g., after Debian security updates):
Server starts, but walreceiver does NOT restart.



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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: BUG??/FEATURE REQUEST: Streaming replication walreceiver doesn't restart after standby reboot with recovery_min_apply_delay
  In-Reply-To: <CAFyWK5f6r51vGL-YroYQczcwY4zTryCoW_NdAVn=LMSMmCEbrw@mail.gmail.com>

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

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox