diff options
author | Tom Lane | 2012-07-13 21:16:58 +0000 |
---|---|---|
committer | Tom Lane | 2012-07-13 21:16:58 +0000 |
commit | b966dd6c4228d696b291c1cdcb5ab8c8475fefa8 (patch) | |
tree | 327dfeb260b8d4523ceb6d793debe86af50d8df2 /doc/src | |
parent | 1a9405d26537c6d95269bf48f5ea80fbf7967260 (diff) |
Add fsync capability to initdb, and use sync_file_range() if available.
Historically we have not worried about fsync'ing anything during initdb
(in fact, initdb intentionally passes -F to each backend launch to prevent
it from fsync'ing). But with filesystems getting more aggressive about
caching data, that's not such a good plan anymore. Make initdb do a pass
over the finished data directory tree to fsync everything. For testing
purposes, the -N/--nosync flag can be used to restore the old behavior.
Also, testing shows that on Linux, sync_file_range() is much faster than
posix_fadvise() for hinting to the kernel that an fsync is coming,
apparently because the latter blocks on a rather small request queue while
the former doesn't. So use this function if available in initdb, and also
in the backend's pg_flush_data() (where it currently will affect only the
speed of CREATE DATABASE's cloning step).
We will later make pg_regress invoke initdb with the --nosync flag
to avoid slowing down cases such as "make check" in contrib. But
let's not do so until we've shaken out any portability issues in this
patch.
Jeff Davis, reviewed by Andres Freund
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/initdb.sgml | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml index 11484468ddd..08ee37e7d86 100644 --- a/doc/src/sgml/ref/initdb.sgml +++ b/doc/src/sgml/ref/initdb.sgml @@ -220,6 +220,21 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>-N</option></term> + <term><option>--nosync</option></term> + <listitem> + <para> + By default, <command>initdb</command> will wait for all files to be + written safely to disk. This option causes <command>initdb</command> + to return without waiting, which is faster, but means that a + subsequent operating system crash can leave the data directory + corrupt. Generally, this option is useful for testing, but should not + be used when creating a production installation. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>--pwfile=<replaceable>filename</></option></term> <listitem> <para> |