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

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(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-22 17:27:58
Message-ID: CAFC+b6p+VZOv0o+Xv_vEc2v6EDCWkEqhK5Y4JVq5S3GD=ro84A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Zsolt,

On Sun, Nov 15, 2026 at 9:45 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
wrote:

> And after thinking about these changes, I realized that both of our
> patches broke standby promotion: both resulted in cases where we
> promoted the standby when we shouldn't have.
>
> The attached v3 now doesn't modify the logic when we have a primary
> connection set, and contains both patches in one file instead.
>

Thanks for v3 patch.

I really like the recoveryStopsAtEndOfWAL() and recoveryTargetReached()
refactoring;
it handles the clean-shutdown and crash-snapshot cases nicely.

The one part I'm not convinced about is leaving the if (rmid != RM_XACT_ID)
return false;
early return in recoveryStopsAfter() and depending on
immediateTargetNeedsNoMoreWAL()
to fetch timeline history when primary_conninfo is set.

v3 only connects to the primary by accident; when the record at
minRecoveryPoint happens
to be a non-transaction record (like the restore point in your test). If
that last record happens to
be a COMMIT instead, recoveryStopsAfter() passes the RM_XACT_ID check, hits
the immediate
check at the bottom, and breaks out of the loop right away.
immediateTargetNeedsNoMoreWAL()
never runs, walreceiver never starts, and we still promote without fetching
the upstream's timeline
history. The same thing already happens on master today for other targets
(xid, name, lsn) when
they are satisfied in local WAL with standby.signal and primary_conninfo
set.

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?

--
Thanks :)
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Nitin Motiani 2026-11-22 17:31:32 Re: BUG #19761: btree_gist: "cannot subtract infinite dates" when inserting 'infinity' into a GiST index on date
Previous Message Kacper Kuras 2026-11-22 16:33:48 Re: BUG #18754: Logical replication cannot restart if client sent a copyDone