| From: | John H <johnhyvr(at)gmail(dot)com> |
|---|---|
| To: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Subject: | Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion |
| Date: | 2025-10-23 22:19:48 |
| Message-ID: | CA+-JvFuSHzzM8yieKOZotNB_ooauKOHaH1HzQUN-_nLdhL51AA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Thu, Oct 23, 2025 at 9:25 AM Andrey Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>
> Hi hackers,
>
> I'd like to propose a new archive_mode setting to address a gap in WAL
> archiving for high availability streaming replication configurations.
>
> In HA setups using streaming replication, standbys can be
> promoted when primary has failed. Some WAL segments might be not yet
> archived. This creates gaps in the WAL archive, breaking point-in-time
> recovery:
>
> 1. Primary generates WAL, streams to standby
> 2. Standby receives WAL, marks segments as .done immediately
+1 to the idea.
If I understand correctly, the assumption we're making is that the Standby
doesn't really "archive" just makes it as .done, even though in theory
it could do the same
thing as the primary and avoid this issue. It would be wasted work if
the primary and replica
archives the same WAL and that's what we want to avoid?
>
> ## Implementation
>
> The patch adds two replication protocol messages:
> - 'a' (PqReplMsg_ArchiveStatusQuery): standby → primary, sends (timeline, segno) pairs
> - 'A' (PqReplMsg_ArchiveStatusResponse): primary → standby, responds with archived pairs
>
I might be missing something but isn't it enough for the writer to
send the last_archived_wal
in PgStat_ArchiverStats? That way we can avoid doing the full
directory scan of archive_status.
Or do we not feel comfortable assuming that WAL files are archived in order?
Thanks,
--
John Hsu - Amazon Web Services
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2025-10-23 22:39:55 | Re: another autovacuum scheduling thread |
| Previous Message | John H | 2025-10-23 22:01:32 | Re: Making pg_rewind faster |