pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: PANIC on fsync() failure.
Date: Mon, 19 Nov 2018 04:45:24 +0000
Message-ID: <E1gObR6-00023g-5u@gemulon.postgresql.org> (raw)

PANIC on fsync() failure.

On some operating systems, it doesn't make sense to retry fsync(),
because dirty data cached by the kernel may have been dropped on
write-back failure.  In that case the only remaining copy of the
data is in the WAL.  A subsequent fsync() could appear to succeed,
but not have flushed the data.  That means that a future checkpoint
could apparently complete successfully but have lost data.

Therefore, violently prevent any future checkpoint attempts by
panicking on the first fsync() failure.  Note that we already
did the same for WAL data; this change extends that behavior to
non-temporary data files.

Provide a GUC data_sync_retry to control this new behavior, for
users of operating systems that don't eject dirty data, and possibly
forensic/testing uses.  If it is set to on and the write-back error
was transient, a later checkpoint might genuinely succeed (on a
system that does not throw away buffers on failure); if the error is
permanent, later checkpoints will continue to fail.  The GUC defaults
to off, meaning that we panic.

Back-patch to all supported releases.

There is still a narrow window for error-loss on some operating
systems: if the file is closed and later reopened and a write-back
error occurs in the intervening time, but the inode has the bad
luck to be evicted due to memory pressure before we reopen, we could
miss the error.  A later patch will address that with a scheme
for keeping files with dirty data open at all times, but we judge
that to be too complicated to back-patch.

Author: Craig Ringer, with some adjustments by Thomas Munro
Reported-by: Craig Ringer
Reviewed-by: Robert Haas, Thomas Munro, Andres Freund
Discussion: https://postgr.es/m/20180427222842.in2e4mibx45zdth5%40alap3.anarazel.de

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/afbe03f6547015790d13d21d5eb5083cc604eeec

Modified Files
--------------
doc/src/sgml/config.sgml                      | 32 ++++++++++++++++++
src/backend/access/heap/rewriteheap.c         |  6 ++--
src/backend/access/transam/slru.c             |  2 +-
src/backend/access/transam/timeline.c         |  4 +--
src/backend/access/transam/xlog.c             |  2 +-
src/backend/replication/logical/snapbuild.c   |  3 ++
src/backend/storage/file/fd.c                 | 48 +++++++++++++++++++++++----
src/backend/storage/smgr/md.c                 |  6 ++--
src/backend/utils/cache/relmapper.c           |  2 +-
src/backend/utils/misc/guc.c                  |  9 +++++
src/backend/utils/misc/postgresql.conf.sample |  1 +
src/include/storage/fd.h                      |  2 ++
12 files changed, 99 insertions(+), 18 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1gObR6-00023g-5u@gemulon.postgresql.org>
Permalink:  ../E1gObR6-00023g-5u@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gObR6-00023g-5u@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tmunro@postgresql.org
  Subject: Re: pgsql: PANIC on fsync() failure.
  In-Reply-To: <E1gObR6-00023g-5u@gemulon.postgresql.org>
  References: <E1gObR6-00023g-5u@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox