Re: pg_basebackup / recovery

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Achilleas Mantzios - cloud <a(dot)mantzios(at)cloud(dot)gatewaynet(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: pg_basebackup / recovery
Date: 2023-04-12 22:31:18
Message-ID: ZDcxNm2xrXHVPybo@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Apr 12, 2023 at 01:45:56PM +0300, Achilleas Mantzios - cloud wrote:
> On 4/12/23 12:32, Fabrice Chapuis wrote:
>> During recovery process of a self contained backup, how postgres know to
>> stop reading wal when consistency is reached?
>
> Because it knows the full packup info. It will observe the
>
> STOP WAL LOCATION: 3BC7/4B000130 (file 0000000200003BC70000004B)
>
> inside the backup file

There is a bit more to that in the recovery logic, depending mostly
on the presence of backup_ label file in the data folder when recovery
begins. Once the backup_label is found at the beginning of recovery,
its information is stored in the control file and the file is renamed
to backup_label.old hence stopping the server when recovery has not
reached its expected point would rely on the control file contents
later on. Then, the startup process and its WAL redo makes sure that
WAL replays until it finds the WAL record marking the end of the
backup. Grepping for XLOG_BACKUP_END (WAL record type in this case)
shows all the areas that rely on that, and xlogrecovery.c covers the
most relevant bits.
--
Michael

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Hennessy 2023-04-12 23:37:41 Re: FW: Error!
Previous Message Rob Sargent 2023-04-12 22:29:54 Re: Guidance on INSERT RETURNING order