Re: Failing assertion while taking a restartpoint during crash recovery
Re: Failing assertion while taking a restartpoint during crash recovery
Hi, I agree that tracking whether StartupSUBTRANS() has actually been called is more direct and robust. I don't have any strong objection to your approach; your fix looks reasonable to me. My initial concern was more about having too many recovery state management variables at this point, i.e., ArchiveRecoveryRequested, InArchiveRecovery, EnableHotStandby, StandbyMode, StandbyModeRequested, etc. I just wanted to keep the context close to the existing states and did not want to create a new state for this specific bug. Thanks, Imran Zaheer On Sat, Aug 15, 2026 at 4:10 PM Fujii Masao wrote: > > On Sat, Aug 15, 2026 at 4:57 PM Imran Zaheer wrote: > > > > Hi > > > > While doing some benchmarking related to my work with the recovery > > pipelining [1], I found that the checkpointer fails when trying to > > take a time-based restartpoint during the crash recovery. > > > > Right now I am facing this assertion failure. > > Thanks for the report! I was also able to reproduce the assertion failure. > > > It looks like the checkpointer is not aware of whether hot standby > > initialization was done during startup, which happens only in the case > > of ArchiveRecoveryRequested [2]. In this specific case, the > > checkpointer assumes hot standby initialization would have been done, > > so it tries to call TruncateSUBTRANS(). A simple fix is to add > > ArchiveRecoveryRequested to recovery shared memory XLogRecoveryCtl; > > then the checkpointer will simply skip TruncateSUBTRANS if archive > > recovery was not requested. I have attached my patch below. > > I think it would be better and more robust to check directly whether > StartupSUBTRANS() has already been called, rather than checking > ArchiveRecoveryRequested, as in the attached patch. > > Thoughts? > > Regards, > > -- > Fujii Masao
Re: Failing assertion while taking a restartpoint during crash recovery
От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Tue, Aug 18, 2026 at 1:37 PM Imran Zaheer wrote: > I was looking into the patch Thanks! > * Instead of setting the shared state in StartupXLOG, why not set it > in the StartupSUBTRANS itself? *If* we take this approach, I think the flag should no longer mean that hot standby initialization has started pg_subtrans, but rather that StartupSUBTRANS() has completed. We would therefore also need to rename the flag and update the comments accordingly. For a bug fix in stable branches, I would prefer to keep the change as small as possible. Also, subtrans.c says that there are no XLOG interactions, so having it update shared recovery state in xlogrecovery.c feels a bit odd to me. I therefore prefer the current patch and approach. > * Other than that we also call TruncateSUBTRANS() while creating a > checkpoint; maybe we can also improve the guard here, although the > assertion under TruncateSUBTRANS could be enough? > > @@ -7879,7 +7878,7 @@ CreateCheckPoint(int flags) > * in subtrans.c). During recovery, though, we mustn't do this because > * StartupSUBTRANS hasn't been called yet. > */ > - if (!RecoveryInProgress()) > + if (!RecoveryInProgress() && RecoverySubtransInitialized()) > TruncateSUBTRANS(GetOldestTransactionIdConsideredRunning()); I don't think this extra check is necessary. If !RecoveryInProgress(), StartupSUBTRANS() should already have been called, so the existing guard should be sufficient. Regards, -- Fujii Masao