pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_basebackup / recovery
4+ messages / 4 participants
[nested] [flat]

* pg_basebackup / recovery
@ 2023-04-12 09:32  Fabrice Chapuis <fabrice636861@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Fabrice Chapuis @ 2023-04-12 09:32 UTC (permalink / raw)
  To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

During recovery process of a self contained backup, how postgres know to
stop reading wal when consistency is reached?

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_basebackup / recovery
@ 2023-04-12 10:45  Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>
  parent: Fabrice Chapuis <fabrice636861@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Achilleas Mantzios - cloud @ 2023-04-12 10:45 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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

  It's a full contained backup because you haven't called with the |-X 
/|method none|/| , and it doesn't get into standby because you haven't 
called with |--write-recovery-conf !|

|I believe by default it will do what you meant that you want.
|

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_basebackup / recovery
@ 2023-04-12 22:31  Michael Paquier <michael@paquier.xyz>
  parent: Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Michael Paquier @ 2023-04-12 22:31 UTC (permalink / raw)
  To: Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>; +Cc: pgsql-general@lists.postgresql.org

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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_basebackup / recovery
@ 2023-04-13 04:06  Achilleas Mantzios <a.mantzios@cloud.gatewaynet.com>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Achilleas Mantzios @ 2023-04-13 04:06 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org

Στις 13/4/23 01:31, ο/η Michael Paquier έγραψε:
> 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.

Thank you for the info!

Sorry about my stupid typo "packup" :(

> --
> Michael

-- 
Achilleas Mantzios
  IT DEV - HEAD
  IT DEPT
  Dynacom Tankers Mgmt






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2023-04-13 04:06 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 09:32 pg_basebackup / recovery Fabrice Chapuis <fabrice636861@gmail.com>
2023-04-12 10:45 ` Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>
2023-04-12 22:31   ` Michael Paquier <michael@paquier.xyz>
2023-04-13 04:06     ` Achilleas Mantzios <a.mantzios@cloud.gatewaynet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox