Re: Does pg_start_backup changes how Postgres writes data?

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Thorsten Schöning <tschoening(at)am-soft(dot)de>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Does pg_start_backup changes how Postgres writes data?
Date: 2019-07-08 08:58:28
Message-ID: CABUevEwnbhfPuVSg-+K8wZdptk0-bpqFA01a=vsqiZY-pixk6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Mon, Jul 8, 2019 at 10:50 AM Thorsten Schöning <tschoening(at)am-soft(dot)de>
wrote:

> Hi all,
>
> we are reviewing our current backup process based on the low level
> pg_start_backup and pg_stop_backup using the exclusive approach.
> During a discussion with one of my coworkers he claimed that after
> pg_start_backup executed, no writes into "the file system" happen
> anymore. The only exception he makes is writes to the WAL.
>

That's incorrect. Writes still happen to the filesystem. Otherwise, the
system might not be able to function properly if the backups take a long
time.

The only difference to writing that pg_start_backup() does is that it
forces full_page_writes to be on during the backup. The only difference to
the non-wal part of the filesystem is the checkpoint, as you mention below.

(Also, you should really look into using the non-exclusive version of
pg_start_backup(), as the exclusive one has several dangers to it. See the
warnings and documentation under 25.3.3.2 at
https://www.postgresql.org/docs/12/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP
--
the same issues apply to previous versions, but the docs were less clear).

From what I understand from reading the docs and multiple other
> sources, I have a different opinion: The only thing pg_start_backup
> changes regarding writes in the data directory of Postgres is that a
> checkpoint is done as part of starting the backup, even if no
> checkpoint would be needed currently otherwise. After that is done,
> from my understanding, Postgres is free to write any file in the
> directory at any given time again however it sees fit. That's why
> inconsistent files are mentioned at many places:
>

This is correct.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Thorsten Schöning 2019-07-08 09:57:07 Do results of pg_start_backup work without WAL segments created during backup?
Previous Message Thorsten Schöning 2019-07-08 08:50:25 Does pg_start_backup changes how Postgres writes data?