Re: pause recovery if pitr target not reached - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: pause recovery if pitr target not reached
Date
Msg-id 20200115.110224.1823671701020745254.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: pause recovery if pitr target not reached  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: pause recovery if pitr target not reached  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
At Tue, 14 Jan 2020 21:13:51 +0100, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in 
> On 2019-12-11 12:40, Leif Gunnar Erlandsen wrote:
> > Adding patch written for 13dev from git
> > "Michael Paquier" <michael@paquier.xyz> skrev 1. desember 2019
> > kl. 03:08:
> > 
> >> On Fri, Nov 22, 2019 at 11:26:59AM +0000, Leif Gunnar Erlandsen wrote:
> >>
> >>> No it does not. It works well to demonstrate its purpose though.
> >>> And it might be to stop with FATAL would be more correct.
> >>
> >> This is still under active discussion. Please note that the latest
> >> patch does not apply, so a rebase would be nice to have. I have moved
> >> the patch to next CF, waiting on author.
> 
> I reworked your patch a bit.  I changed the outcome to be an error, as
> was discussed.  I also added tests and documentation.  Please take a
> look.

It doesn't show how far the last recovery actually reached. I don't
think activating resource managers harms. Don't we check the
not-reached condition *only* after the else block of the "if (record
!= NULL)" statement?

>     /* just have to read next record after CheckPoint */
>     record = ReadRecord(xlogreader, InvalidXLogRecPtr, LOG, false);
>   }
>
>   if (record != NULL)
>   {
>    ...
>    }
>    else
>    {
>      /* there are no WAL records following the checkpoint */
>      ereport(LOG,
>          (errmsg("redo is not required")));
>   }
>
+   if (recoveryTarget != RECOVERY_TARGET_UNSET && !reachedStopPoint)
..


recvoery_target_* is not cleared after startup. If a server crashed
just after the last shutdown checkpoint, any recovery_target_* setting
prevents the server from starting regardless of its value.

> LOG:  database system was not properly shut down; automatic recovery in progress
> LOG:  invalid record length at 0/9000420: wanted 24, got 0
(recovery is skipped)
> FATAL:  recovery ended before configured recovery target was reached

I think we should ignore the setting while crash recovery. Targeted
recovery mode is documented as a feature of archive recovery.  Perhaps
ArchiveRecoveryRequested is needed in the condition.

> if (ArchiveRecoveryRequested &&
>     recoveryTarget != RECOVERY_TARGET_UNSET && !reachedStopPoint)
     
regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: logical decoding : exceeded maxAllocatedDescs for .spill files
Next
From: Peter Geoghegan
Date:
Subject: Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.