| From: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
|---|---|
| To: | zsolt(dot)parragi(at)percona(dot)com |
| Cc: | srinath2133(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" |
| Date: | 2026-11-25 08:30:06 |
| Message-ID: | 20261125.173006.864309580335348003.horikyota.ntt@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hello,
At Tue, 24 Nov 2026 16:44:05 -0600, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote in
> 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.
I would suggest a somewhat different approach to fixing the first two
cases, as shown in the attached patches.
For the first case, rather than moving the immediate target check
before the processing of transaction completion records, I removed
the early return and made the rmgr check part of the condition again,
as it was before commit 4f1b890b137. This ensures that the latest
transaction timestamp is updated before checking the immediate target.
I also moved the LSN target check after the processing of transaction
completion records for the same reason.
For the second case, rather than introducing a separate check for
the immediate target at the end of WAL, I made recoveryStopsAfter()
accept an XLogReaderState without a valid record. In that case,
it skips all record-dependent processing and only checks the
immediate target. This allows us to reuse the existing recovery
target check after exiting the main redo loop without duplicating
the logic.
The proposed tests seem a bit too heavyweight to me, so I added a
smaller regression test to each patch, reusing the existing test
infrastructure where possible.
> 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:
...
> 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)
The documentation seems open to either interpretation. In practice,
though, I seem to recall seeing HA setups where a primary is shut
down in immediate mode and then restarted as a standby, albeit
without specifying a recovery target.
In any case, I think we should focus on the first two cases here and
discuss the timeline issue separately.
Regards,
--
Kyotaro Horiguchi
NTT Open Source Software Center
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-Fix-recovery-target-checks-after-applying-WAL-rec.patch | text/x-patch | 6.1 KB |
| v3-0002-Check-the-immediate-recovery-target-at-end-of-WAL.patch | text/x-patch | 4.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Xuneng Zhou | 2026-11-25 09:13:57 | Re: Lost walsender wakeup stalls synchronous commits until the standby's next reply (16+) |
| Previous Message | Fujii Masao | 2026-11-25 07:47:05 | Re: Lost walsender wakeup stalls synchronous commits until the standby's next reply (16+) |