Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"
Date: 2026-11-24 22:44:05
Message-ID: CAN4CZFMf=tY+6UhxYMh4OjJJVMvJpMQUgfNAWR4GOQra9SOOEQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, 22 Nov 2026, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com> wrote:
> I'd rather we fix recoveryStopsAfter() (as in 0001) so immediate works the
> same for all record types,
> keep your recoveryStopsAtEndOfWAL() changes for the no-redo and end-of-WAL
> cases, and leave
> the timeline-history question for a separate patch if we want to enforce
> that for all recovery targets.
>
> wdyt?

I agree that keeping 0001 and adding my changes on top of it would be
better, and that's why I tried that initially. And I again attached a
v4 in that shape, however: it has a regression compared to v3.

A backup restored as a standby, with recovery_target = 'immediate' and
recovery_target_action = 'promote', picks a timeline its upstream
already uses. Master avoids it only because of where the WAL happens
to end, by accident. Your 0001 removes that accident, so the scenario
starts to fail:

P (primary, TLI 1) ──stream──> S (standby)

1. P: pg_create_restore_point() -> RP record at LSN X
2. S replays up to the end of RP
3. P killed (-m immediate) -> no more WAL on TLI 1
4. backup B taken from S -> backup end = S's
minRecoveryPoint = end of RP
5. S promoted -> TLI 2, switchpoint = end of RP,
00000002.history only in S's pg_wal
6. S inserts a row on TLI 2
7. B restored as node N: standby.signal, primary_conninfo = S,
recovery_target = 'immediate', action = promote,
restore_command finds nothing (no shared archive)

On master, we get TLI 3, with 0001, we get TLI 2: N and S both run TLI
2, both fork from TLI 1 at the same switchpoint, but their WAL after
that differs.

But this is an odd setup, and corner case even in that, so breaking it
is most likely okay. (And I think there was another thread discussing
this issue in more general, that timelines should have some other
identifiers other than numbers? But I can't find it now)

Attachment Content-Type Size
v4-0001-Fix-recovery_target-immediate-when-WAL-ends-at-th.patch text/x-patch 2.0 KB
v4-0002-Fix-immediate-recovery-targets-without-a-record-t.patch text/x-patch 13.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Zhijie Hou 2026-11-25 02:28:18 Re: Inactive physical replication slot can bypass synchronized_standby_slots confirmation
Previous Message Zsolt Parragi 2026-11-24 22:11:37 Re: Timing issue in pg_basebackup