Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Roman Khapov <rkhapov(at)yandex-team(dot)ru>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, johnhyvr(at)gmail(dot)com, Kirill Reshke <reshke(at)yandex-team(dot)ru>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion
Date: 2026-02-12 08:53:02
Message-ID: 96531FE1-1118-47C5-B7C1-70369182719E@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 22 Dec 2025, at 19:10, Roman Khapov <rkhapov(at)yandex-team(dot)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 matches the “shared” archive design: the primary pushes archive status over the replication protocol, so the standby never needs to scan or query.

Fujii: You suggested coordinating via pg_stat_archiver on the primary instead of hitting storage. The shared archive approach does 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 originally proposed: 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 gets confirmation. 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 be more appropriate to work in this thread?

Best regards, Andrey Borodin.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-02-12 09:18:53 Re: Add 64-bit XIDs into PostgreSQL 15
Previous Message Jakub Wartak 2026-02-12 08:35:06 Re: pg_stat_io_histogram