Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion
Date
Msg-id 96531FE1-1118-47C5-B7C1-70369182719E@yandex-team.ru
Whole thread
In response to Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion  (Roman Khapov <rkhapov@yandex-team.ru>)
List pgsql-hackers

> On 22 Dec 2025, at 19:10, Roman Khapov <rkhapov@yandex-team.ru> wrote:
>
> some improvement possibilities

Hi John, Fujii, Roman, Kirill and everyone who commented,

Thanks for the feedback on the follow_primary patch!
Your suggestions pointed toward a simpler design.

John: You suggested having the primary send last_archived_wal instead of the standby scanning archive_status. That
matchesthe “shared” archive design: the primary pushes archive status over the replication protocol, so the standby
neverneeds to scan or query. 

Fujii: You suggested coordinating via pg_stat_archiver on the primary instead of hitting storage. The shared archive
approachdoes exactly that: coordination stays inside the cluster via the replication protocol, with no extra storage
requests.

I’ve started implementing this in Heikki Linnakangas’s old thread (2014), where the “shared” archive idea was
originallyproposed:
https://www.postgresql.org/message-id/flat/D4B53AE3-B7AF-4BE6-9CB6-44956B05DE72%40yandex-team.ru#819292ccc2235cfb5d417d2925517664

The design: primary sends archive status reports; standby creates .ready for received WAL and marks .done only after it
getsconfirmation. No standby-initiated queries, no directory scans on the standby, no extra storage calls. 

I posted the implementation there and will circle back to this thread when there’s an update. Or do you think it ouwld
bemore appropriate to work in this thread? 


Best regards, Andrey Borodin.


pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: pg_stat_io_histogram
Next
From: Heikki Linnakangas
Date:
Subject: Re: Add 64-bit XIDs into PostgreSQL 15