| From: | Shlomi Noach <shlomi(at)planetscale(dot)com> |
|---|---|
| To: | João Rito <joaovictor(dot)rito(at)gmail(dot)com> |
| Cc: | Филиппов Степан <stepan(dot)filippov(at)yandex(dot)ru>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "heikki(dot)linnakangas(at)iki(dot)fi" <heikki(dot)linnakangas(at)iki(dot)fi>, Michael Paquier <michael(at)paquier(dot)xyz> |
| Subject: | Re: [PATCH] Fix timeline history after recovery stops on an ancestor |
| Date: | 2026-12-06 10:54:25 |
| Message-ID: | CAEQBPGrS2-OcRGkFGj+0f6k=7K+Bqsk53R5qEK+=p_M4XAXhVg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Nov 10, 2026 at 05:14 AM, João Rito wrote:
> Do you know of a case where this breaks something ... If so, it would be
> good to mention it in the commit message, since it helps decide whether to
> back-patch.
Yes. We run Postgres 18 as a managed service, and we hit this in production
restores. The setup is the one in Stepan's first email: a PITR restore with
recovery_target_timeline = 'latest', a target A on timeline 1, and an
archive that also has timeline 2, forked later at B (after a switchover).
The restored node pauses at A, and we promote it. The promotion creates
timeline 3, and its history file (00000003.history) lists timeline 1
ending at B and timeline 2 ending at A.
We see two failures:
1. A standby of the promoted node replays past A. The attached TAP test
(prefixed nocfbot- so the CommitFest bot ignores it) reproduces it on
master (8d90516d76d) and on our 18.7 build: a standby made from the
original base backup, streaming from the promoted node, streams
timeline 1 from before A, replays the rows the PITR excluded, and then
stalls at "record with incorrect prev-link" without ever reaching
timeline 3. With v2 applied, all of its checks pass, and so do
002_archiving.pl and 028_pitr_timelines.pl.
2. Tools that read the history file cannot build a valid chain from it.
Our archiver checks that switch points increase before it uploads a
segment. It refused every segment on the new timeline, so WAL archiving
stopped on the restored cluster.
The data on the promoted node itself was correct. Archive recovery along
timeline 3 from the original base backup also gets the right rows, because
it reads each segment from the newest timeline that has it; the test checks
that too.
For now we work around it by pinning recovery_target_timeline to the
timeline that holds the target before we promote. The workaround is
fragile, so we would like to see this fix back-patched.
Thanks,
Shlomi
| Attachment | Content-Type | Size |
|---|---|---|
| nocfbot-0001-Test-PITR-to-an-ancestor-timeline-followed-by-a-stan.patch | application/octet-stream | 8.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-12-06 11:48:53 | Re: extremely slow planner when DISTINCT clause holds more columns |
| Previous Message | Manu | 2026-12-06 07:40:49 | Re: Proposal: "query_work_mem" GUC, to distribute working memory to the query's individual operators |