Re: [HACKERS] Reading backup label file for checkpoint and redolocation during crash recovery - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: [HACKERS] Reading backup label file for checkpoint and redolocation during crash recovery
Date
Msg-id 20170925174332.GZ4628@tamriel.snowman.net
Whole thread Raw
In response to [HACKERS] Reading backup label file for checkpoint and redo location duringcrash recovery  (Satyanarayana Narlapuram <Satyanarayana.Narlapuram@microsoft.com>)
Responses Re: [HACKERS] Reading backup label file for checkpoint and redolocation during crash recovery  (Andres Freund <andres@anarazel.de>)
Re: [HACKERS] Reading backup label file for checkpoint and redolocation during crash recovery  (Magnus Hagander <magnus@hagander.net>)
List pgsql-hackers
Greetings Satya,

* Satyanarayana Narlapuram (Satyanarayana.Narlapuram@microsoft.com) wrote:
> During crash recovery, last checkpoint record information is obtained from the backup label if present, instead of
gettingit from the control file. This behavior is causing PostgreSQL database cluster not to come up until the backup
labelfile is deleted (as the error message says). 
>
> if (checkPoint.redo < checkPointLoc)
>                       {
>                              if (!ReadRecord(xlogreader, checkPoint.redo, LOG, false))
>                                     ereport(FATAL,
>                                                   (errmsg("could not find redo location referenced by checkpoint
record"),
>                                                   errhint("If you are not restoring from a backup, try removing the
file\"%s/backup_label\".", DataDir))); 
>                       }
>
> If we are recovering from a dump file, reading from the backup label files makes sense as the control file could be
archivedafter a few checkpoints. But this is not the case for crash recovery, and is always safe to read the checkpoint
recordinformation from the control file. 
> Is this behavior kept this way as there is no clear way to distinguish between the recovery from the dump and the
regularcrash recovery? 

This is why the exclusive backup method has been deprecated in PG10 in
favor of the non-exclusive backup method, which avoids this by not
creating a backup label file (it's up to the backup software to store
the necessary information and create the file for use during recovery).

Please see:

https://www.postgresql.org/docs/10/static/continuous-archiving.html

In particular, section 25.3.3.

Thanks!

Stephen

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [HACKERS] Built-in plugin for logical decoding output
Next
From: "Rady, Doug"
Date:
Subject: [HACKERS] PATCH: pgbench - break out timing data for initialization phases