WAL segment switch on pg_start_backup() - Mailing list pgsql-hackers

From @usernamedt
Subject WAL segment switch on pg_start_backup()
Date
Msg-id sXJWGFbMHtqtkwUst44o733l-dZNBGKY85Y0-47BvPWcyq-zVsHuOhDyI4TW51XR7FUrPejAFXVUh3evFciDWEYq_MSUmZ9fG0LvrSodnIk=@protonmail.ch
Whole thread Raw
List pgsql-hackers
Hi,

I am currently exploring the pg_start_backup() and pg_stop_backup() functions.

In the documentation (https://www.postgresql.org/docs/9.0/functions-admin.html), it is stated that after calling pg_stop_backup() Postgres switches to the new WAL segment file. But it doesn’t say the same for pg_start_backup().

However, I found the following comment regarding pg_start_backup() in the source code:


* Force an XLOG file switch before the checkpoint, to ensure that the
* WAL segment the checkpoint is written to doesn't contain pages with
* old timeline IDs.  That would otherwise happen if you called
* pg_start_backup() right after restoring from a PITR archive: the
* first WAL segment containing the startup checkpoint has pages in
* the beginning with the old timeline ID.  That can cause trouble at
* recovery: we won't have a history file covering the old timeline if
* pg_wal directory was not included in the base backup and the WAL
* archive was cleared too before starting the backup.

So does it mean that Postgres always switches to the new WAL segment file on pg_start_backup() call too?

If so, as I understood, the newly created WAL segment file should start from the checkpoint and should not contain any WAL records regarding the events that happened before pg_start_backup() call?

Thanks,
Daniil Zakhlystov

pgsql-hackers by date:

Previous
From: Amul Sul
Date:
Subject: Re: new heapcheck contrib module
Next
From: Dean Rasheed
Date:
Subject: Re: Wrong results from in_range() tests with infinite offset