Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vxOX3-00Br6A-0m for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Mar 2026 12:07:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vxOX1-006tDw-1M for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Mar 2026 12:07:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vxOX1-006tDZ-01 for pgsql-hackers@lists.postgresql.org; Tue, 03 Mar 2026 12:07:19 +0000 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vxOWy-00000000Auy-0aMT for pgsql-hackers@postgresql.org; Tue, 03 Mar 2026 12:07:18 +0000 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 0852BC01BA; Tue, 03 Mar 2026 15:07:11 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6bf:8080:672::1:1c]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 87mWk20AjKo0-fYp8McA4; Tue, 03 Mar 2026 15:07:10 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1772539630; bh=K98oAg230ftfsePDtIAvtg9RI3d260yfkRJLEg1y/iw=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=rr/ABMGiAeJSsXDMuU30ebdKBJ5ZP5cuxqdjDU9TGfxMjYtgpHYPYAU4VeXCg+4zF cI7DeUlnDUjILBuEzSvB6wVsb9UBKNoPA7KtXAJ74NiEB7zjd8x/QBtCq35E1WeTBx 5dafXQcxlZZwD7ma87kJs82qpJT3XDuXqnbJ9BRg= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Streaming replication and WAL archive interactions From: Jaroslav Novikov In-Reply-To: Date: Tue, 3 Mar 2026 15:06:58 +0300 Cc: hlinnaka@iki.fi, Michael Paquier , Robert Haas , Venkata Balaji N , Andres Freund , Fujii Masao , Borodin Vladimir , PostgreSQL-development , nkak@vmware.com, Roman Khapov , Kirill Reshke , ShirishaRao@vmware.com Content-Transfer-Encoding: quoted-printable Message-Id: <9A271666-C8DA-455E-B5C7-48FF01CC72AB@yandex-team.ru> References: <548AF1CB.80702@vmware.com> <689EB259-44C2-4820-B901-4F6B1C55A1E4@simply.name> <549083D6.1000301@vmware.com> <54949108.3030109@vmware.com> <552FA38F.9060005@iki.fi> <5535FE71.1010905@iki.fi> <55362CAD.2000207@iki.fi> <553741FE.1080403@iki.fi> <554CB84E.3070406@iki.fi> <5550D20D.6090703@iki.fi> To: Andrey Borodin X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 12 Feb 2026, at 09:56, Andrey Borodin wrote: >=20 > Hi Heikki, >=20 > There=E2=80=99s a nearby thread [0] (about 10 years later) where I=E2=80= =99m working on a problem your patch from this thread helps solve. >=20 > In datacenter large outages, 1=E2=80=932% of clusters end up with gaps = in their PITR timeline. > In HA setups, when the primary is lost, some WAL can be missing from = the archive even though it was streamed to the standby. Many HA tools = (PGConsul, Patroni, etc.) try to re-archive from the standby, but those = WAL files may already have been removed. >=20 > Your =E2=80=9Cshared=E2=80=9D archive mode addresses this: the standby = keeps WAL until it=E2=80=99s archived. archive_mode=3Dalways plus an = archive tool can work, but it=E2=80=99s expensive. In WAL-G, for = example, the archive command does a GET on the standby=E2=80=99s WAL, = then decrypts and compares. Switching to HEAD would reduce cost in some = clouds but still adds cost. >=20 > Another option is coordinating archiving outside Postgres, but that = would mean building distributed coordination into the archive tool. >=20 > Shared archive mode tackles this in Postgres itself. >=20 > I=E2=80=99ve retrofitted your patch, incorporated ideas from the = Greenplum work [1], and made some improvements. >=20 > The patchset has three parts: > * Rebase + tests =E2=80=93 Your original patch, rebased, with tests = added. > * Timeline switching =E2=80=93 Correct handling of timeline switches = in archive status updates. > * Avoid directory scans =E2=80=93 Skip scanning archive_status when = possible, which was costly in WAL-G setups. >=20 > What do you think? >=20 > Best regards, Andrey Borodin. >=20 > = Hi Andrey, Adding the missing references [0] and [1]. [0] https://www.postgresql.org/message-id/5550D20D.6090703%40iki.fi [1] = https://github.com/open-gpdb/gpdb/commit/4f2db1929df1b5eed28f3350595563609= 6bb4e8b Best, Jaroslav Novikov.