Re: Switching XLog source from archive to streaming when primary available

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Ian Lawrence Barwick <barwick(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Cary Huang <cary(dot)huang(at)highgo(dot)ca>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Switching XLog source from archive to streaming when primary available
Date: 2026-09-23 09:51:00
Message-ID: CAE9k0Pkfx3+BD1=tzRCZxUv9ChN03J591pnGwBhXaJSsNB8iBg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Here is the newer version of the patch, based on the earlier v24
version shared by Bharath here: [1].

I have slightly simplified the patch, while preserving its original semantics.

The patch introduces a timeout-based server parameter,
"streaming_replication_retry_interval". When a standby has been
reading WAL from the archive for the configured interval, it attempts
to switch to streaming replication. Before doing so, it first ensures
that all WAL already available under the pg_wal directory has been
consumed. If streaming starts successfully, it continues using the
streaming source. Otherwise, it falls back to archive recovery.

Here is how the flow looks:

ARCHIVE
|
| timeout
v
DRAIN LOCAL pg_wal
|
| no local WAL remains
v
STREAMING
|
| streaming fails
v
ARCHIVE

Please have a look and let me know your thoughts.

[1] - https://www.postgresql.org/message-id/CALj2ACVVM8c9pbCgmyxvViFy%3Df%3D%3DQNHhPFSGjvq0Sz7Y0beZsw%40mail.gmail.com

--
With Regards,
Ashutosh Sharma.

Attachment Content-Type Size
v25-0001-Allow-standby-to-switch-its-WAL-source-from-archive-.patch application/octet-stream 16.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeevan Chalke 2026-09-23 09:54:18 Re: Use-after-free of a shared Path in add_path()/add_partial_path()
Previous Message Yuhang Qiu 2026-09-23 09:44:29 [PATCH] Add ALTER SYSTEM RELOAD