On Wed, Sep 10, 2025 at 1:59 AM Melanie Plageman
<melanieplageman@gmail.com> wrote:
>
> Thanks for taking time to reply!
>
> On Wed, Sep 3, 2025 at 11:38 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> >
> > On Sat, Aug 30, 2025 at 4:16 AM Melanie Plageman
> > <melanieplageman@gmail.com> wrote:
> >
> > > Why is it okay for other processes than the startup process to
> > > initialize LocalMinRecoveryPoint from ControlFile->minRecoveryPoint
> > > during crash recovery?
> >
> > During crash recovery we don't yet know the minRecoveryPoint until we
> > replay all the WALs and once it is done it will be updated in the
> > ControlFile at PerformRecoveryXLogAction()->CreateEndOfRecoveryRecord().
> > After this point it will be valid to use by any process including the
> > StartupProcess. So I don't think until ControlFile->minRecoveryPoint
> > is initialized it is safe to use for any process. In fact, before any
> > connections are allowed this has to be set either by
> > CreateEndOfRecoveryRecord() if recovering a primary from crash or by
> > ReachedEndOfBackup() if you are starting a standby from backup.
>
> So, looking at the code, it seems like most places we examine
> ControlFile->minRecoveryPoint, we condition it on "InArchiveRecovery".
> Is this something we want to do in XLogNeedsFlush() to avoid reading
> from ControlFile->minRecoveryPoint()?
>
> Though, it seems like LocalMinRecoveryPoint must be getting
> incorrectly set elsewhere, otherwise this would have guarded us from
> examining the control file:
>
> if (XLogRecPtrIsInvalid(LocalMinRecoveryPoint) && InRecovery)
> updateMinRecoveryPoint = false;
>
> /* Quick exit if already known to be updated or cannot be updated */
> if (record <= LocalMinRecoveryPoint || !updateMinRecoveryPoint)
> return false;
That's not quite right. Before the end-of-recovery checkpoint, the
InRecovery flag is already set to false. This means that even if
LocalMinRecoveryPoint is invalid, it won't matter, and
updateMinRecoveryPoint will not be set to false. Since
LocalMinRecoveryPoint is 0, the condition if (record <=
LocalMinRecoveryPoint) will also fail, causing the process to continue
and read from the ControlFile.
--
Regards,
Dilip Kumar
Google