postgresql/src/include/storage
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
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
barrier.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
block.h Assorted minor doc/comment fixes. 2018-04-28 11:46:15 -04:00
buf.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
buf_internals.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
buffile.h Use 64 bit type for BufFileSize(). 2018-11-15 13:13:57 +13:00
bufmgr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
bufpage.h Revert "Allow on-line enabling and disabling of data checksums" 2018-04-09 19:03:42 +02:00
checksum.h Revert "Allow on-line enabling and disabling of data checksums" 2018-04-09 19:03:42 +02:00
checksum_impl.h Make checksum_impl.h safe to compile with -fstrict-aliasing. 2018-08-31 12:26:20 -04:00
condition_variable.h Allow ConditionVariable[PrepareTo]Sleep to auto-switch between CVs. 2018-01-09 11:39:10 -05:00
copydir.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dsm.h Remove dsm_resize() and dsm_remap(). 2018-11-06 16:11:12 +13:00
dsm_impl.h Remove dsm_resize() and dsm_remap(). 2018-11-06 16:11:12 +13:00
fd.h PANIC on fsync() failure. 2018-11-19 17:41:26 +13:00
freespace.h Remove UpdateFreeSpaceMap(), use FreeSpaceMapVacuumRange() instead. 2018-03-29 12:22:44 -04:00
fsm_internals.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
indexfsm.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ipc.h Fix crash when canceling parallel query 2018-02-16 16:21:24 -05:00
item.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
itemid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
itemptr.h Improve representation of 'moved partitions' indicator on deleted tuples. 2018-05-01 13:30:12 -07:00
large_object.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
latch.h Fix misc typos, mostly in comments. 2018-07-18 16:17:32 +03:00
lmgr.h Add assertions that we hold some relevant lock during relation open. 2018-10-01 12:43:21 -04:00
lock.h Add assertions that we hold some relevant lock during relation open. 2018-10-01 12:43:21 -04:00
lockdefs.h Add assertions that we hold some relevant lock during relation open. 2018-10-01 12:43:21 -04:00
lwlock.h Correct constness of a few variables. 2018-10-15 21:01:14 -07:00
off.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_sema.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_shmem.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pmsignal.h Add missing header include to pmsignal.h. 2018-08-02 12:14:22 +12:00
predicate.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
predicate_internals.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
proc.h Make autovacuum more aggressive to remove orphaned temp tables 2018-08-13 11:49:04 +02:00
procarray.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
proclist.h Improve error detection capability in proclists. 2018-01-08 18:07:04 -05:00
proclist_types.h Improve error detection capability in proclists. 2018-01-08 18:07:04 -05:00
procsignal.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
reinit.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
relfilenode.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
s_lock.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sharedfileset.h Fix more wrong paths in header comments 2018-07-11 17:57:04 +03:00
shm_mq.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
shm_toc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
shmem.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sinval.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sinvaladt.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
smgr.h Improve the performance of relation deletes during recovery. 2018-07-05 02:23:46 +09:00
spin.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
standby.h Remove AELs from subxids correctly on standby 2018-06-16 14:03:29 +01:00
standbydefs.h Fix bugs in vacuum of shared rels, by keeping their relcache entries current. 2018-06-12 11:13:21 -07:00