postgresql/src/backend/utils
Thomas Munro 9ccdd7f66e 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
2018-11-19 17:41:26 +13:00
..
adt Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
cache PANIC on fsync() failure. 2018-11-19 17:41:26 +13:00
error Disallow setting client_min_messages higher than ERROR. 2018-11-08 17:33:43 -05:00
fmgr Drop const cast from dlsym() calls 2018-10-23 14:35:59 +02:00
hash Allow memory contexts to have both fixed and variable ident strings. 2018-03-27 16:46:51 -04:00
init Refactor pid, random seed and start time initialization. 2018-10-19 13:59:28 +13:00
mb Const-ify a few more large static tables. 2018-10-17 15:32:47 -04:00
misc PANIC on fsync() failure. 2018-11-19 17:41:26 +13:00
mmgr Simplify use of AllocSetContextCreate() wrapper macro. 2018-10-12 14:26:56 -04:00
resowner Use a ResourceOwner to track buffer pins in all cases. 2018-07-18 12:15:16 -04:00
sort Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
time Fix misc typos, mostly in comments. 2018-07-18 16:17:32 +03:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
Gen_dummy_probes.pl Clean up some perlcritic warnings 2018-05-07 15:35:32 -04:00
Gen_dummy_probes.sed Update copyright for 2018 2018-01-02 23:30:12 -05:00
Gen_fmgrtab.pl Reorder FmgrBuiltin members, saving 25% in size. 2018-10-16 14:51:18 -07:00
Makefile Suppress compiler warnings when building with --enable-dtrace. 2018-05-07 13:44:09 -04:00
errcodes.txt Relax transactional restrictions on ALTER TYPE ... ADD VALUE (redux). 2018-10-09 12:51:01 +13:00
generate-errcodes.pl Update copyright for 2018 2018-01-02 23:30:12 -05:00
probes.d Support parallel btree index builds. 2018-02-02 13:32:44 -05:00