1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-22 17:42:17 +03:00

Allow using syncfs() in frontend utilities.

This commit allows specifying a --sync-method in several frontend
utilities that must synchronize many files to disk (initdb,
pg_basebackup, pg_checksums, pg_dump, pg_rewind, and pg_upgrade).
On Linux, users can specify "syncfs" to synchronize the relevant
file systems instead of calling fsync() for every single file.  In
many cases, using syncfs() is much faster.

As with recovery_init_sync_method, this new option comes with some
caveats.  The descriptions of these caveats have been moved to a
new appendix section in the documentation.

Co-authored-by: Justin Pryzby
Reviewed-by: Michael Paquier, Thomas Munro, Robert Haas, Justin Pryzby
Discussion: https://postgr.es/m/20210930004340.GM831%40telsasoft.com
This commit is contained in:
Nathan Bossart
2023-09-06 16:27:16 -07:00
parent cccc6cdeb3
commit 8c16ad3b43
21 changed files with 271 additions and 11 deletions

View File

@@ -365,6 +365,28 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry id="app-initdb-option-sync-method">
<term><option>--sync-method</option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>initdb</command> will recursively open and synchronize all
files in the data directory. The search for files will follow symbolic
links for the WAL directory and each configured tablespace.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file systems that contain the
data directory, the WAL files, and each tablespace. See
<xref linkend="syncfs"/> for more information about using
<function>syncfs()</function>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry id="app-initdb-option-sync-only">
<term><option>-S</option></term>
<term><option>--sync-only</option></term>

View File

@@ -594,6 +594,31 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--sync-method</option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>pg_basebackup</command> will recursively open and synchronize
all files in the backup directory. When the plain format is used, the
search for files will follow symbolic links for the WAL directory and
each configured tablespace.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file system that contains the
backup directory. When the plain format is used,
<command>pg_basebackup</command> will also synchronize the file systems
that contain the WAL files and each tablespace. See
<xref linkend="syncfs"/> for more information about using
<function>syncfs()</function>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>

View File

@@ -139,6 +139,28 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--sync-method</option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>pg_checksums</command> will recursively open and synchronize
all files in the data directory. The search for files will follow
symbolic links for the WAL directory and each configured tablespace.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file systems that contain the
data directory, the WAL files, and each tablespace. See
<xref linkend="syncfs"/> for more information about using
<function>syncfs()</function>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>

View File

@@ -1179,6 +1179,27 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--sync-method</option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>pg_dump --format=directory</command> will recursively open and
synchronize all files in the archive directory.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file system that contains the
archive directory. See <xref linkend="syncfs"/> for more information
about using <function>syncfs()</function>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used or
<option>--format</option> is not set to <literal>directory</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--table-and-children=<replaceable class="parameter">pattern</replaceable></option></term>
<listitem>

View File

@@ -284,6 +284,28 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--sync-method</option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>pg_rewind</command> will recursively open and synchronize all
files in the data directory. The search for files will follow symbolic
links for the WAL directory and each configured tablespace.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file systems that contain the
data directory, the WAL files, and each tablespace. See
<xref linkend="syncfs"/> for more information about using
<function>syncfs()</function>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option></term>
<term><option>--version</option></term>

View File

@@ -190,6 +190,29 @@ PostgreSQL documentation
variable <envar>PGSOCKETDIR</envar></para></listitem>
</varlistentry>
<varlistentry>
<term><option>--sync-method</option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>pg_upgrade</command> will recursively open and synchronize all
files in the upgraded cluster's data directory. The search for files
will follow symbolic links for the WAL directory and each configured
tablespace.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file systems that contain the
upgraded cluster's data directory, its WAL files, and each tablespace.
See <xref linkend="syncfs"/> for more information about using
<function>syncfs()</function>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-U</option> <replaceable>username</replaceable></term>
<term><option>--username=</option><replaceable>username</replaceable></term>