WAL segment switch on pg_start_backup()

From: "(at)usernamedt" <usernamedt(at)protonmail(dot)ch>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: WAL segment switch on pg_start_backup()
Date: 2020-07-21 07:51:56
Message-ID: sXJWGFbMHtqtkwUst44o733l-dZNBGKY85Y0-47BvPWcyq-zVsHuOhDyI4TW51XR7FUrPejAFXVUh3evFciDWEYq_MSUmZ9fG0LvrSodnIk=@protonmail.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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:

Excerpt from Postgres source code https://doxygen.postgresql.org/xlog_8c_source.html#l10595

* 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2020-07-21 08:06:09 Re: Wrong results from in_range() tests with infinite offset
Previous Message Amul Sul 2020-07-21 06:50:52 Re: new heapcheck contrib module