pgsql: Fix fsync-at-startup code to not treat errors as fatal.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix fsync-at-startup code to not treat errors as fatal.
Дата
Msg-id E1Yy5Qb-0000wg-Bz@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix fsync-at-startup code to not treat errors as fatal.

Commit 2ce439f3379aed857517c8ce207485655000fc8e introduced a rather serious
regression, namely that if its scan of the data directory came across any
un-fsync-able files, it would fail and thereby prevent database startup.
Worse yet, symlinks to such files also caused the problem, which meant that
crash restart was guaranteed to fail on certain common installations such
as older Debian.

After discussion, we agreed that (1) failure to start is worse than any
consequence of not fsync'ing is likely to be, therefore treat all errors
in this code as nonfatal; (2) we should not chase symlinks other than
those that are expected to exist, namely pg_xlog/ and tablespace links
under pg_tblspc/.  The latter restriction avoids possibly fsync'ing a
much larger part of the filesystem than intended, if the user has left
random symlinks hanging about in the data directory.

This commit takes care of that and also does some code beautification,
mainly moving the relevant code into fd.c, which seems a much better place
for it than xlog.c, and making sure that the conditional compilation for
the pre_sync_fname pass has something to do with whether pg_flush_data
works.

I also relocated the call site in xlog.c down a few lines; it seems a
bit silly to be doing this before ValidateXLOGDirectoryStructure().

The similar logic in initdb.c ought to be made to match this, but that
change is noncritical and will be dealt with separately.

Back-patch to all active branches, like the prior commit.

Abhijit Menon-Sen and Tom Lane

Branch
------
REL9_2_STABLE

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

Modified Files
--------------
src/backend/access/transam/xlog.c |   54 ++-----
src/backend/storage/file/fd.c     |  315 +++++++++++++++++++++++++++++--------
src/include/storage/fd.h          |    3 +-
3 files changed, 259 insertions(+), 113 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix fsync-at-startup code to not treat errors as fatal.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix fsync-at-startup code to not treat errors as fatal.