pgsql: Add fsync capability to initdb, and use sync_file_range() if ava

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Add fsync capability to initdb, and use sync_file_range() if ava
Дата
Msg-id E1SpnEc-0007qr-Dj@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b966dd6c4228d696b291c1cdcb5ab8c8475fefa8

Modified Files
--------------
configure                     |    3 +-
configure.in                  |    2 +-
doc/src/sgml/ref/initdb.sgml  |   15 +++
src/backend/storage/file/fd.c |    7 +-
src/bin/initdb/initdb.c       |  230 ++++++++++++++++++++++++++++++++++++++++-
src/include/pg_config.h.in    |    3 +
src/include/pg_config.h.win32 |    3 +
7 files changed, 258 insertions(+), 5 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Cosmetic cleanup of ginInsertValue().
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Add link to PEP 394 regarding python2 vs python3 naming