postgresql/src/include
Thomas Munro afbe03f654 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 13:40:57 +13:00
..
access Rename rbtree.c functions to use "rbt" prefix not "rb" prefix. 2018-11-06 13:25:24 -05:00
bootstrap Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catalog Fix missing role dependencies for some schema and type ACLs. 2018-11-09 20:42:03 -05:00
commands Mark assorted variables PGDLLIMPORT. 2017-12-05 09:24:05 -05:00
common Increase SCRAM salt length 2017-08-24 14:08:23 -04:00
datatype Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
executor Fix failure with initplans used conditionally during EvalPlanQual rechecks. 2018-09-15 13:42:34 -04:00
fe_utils Empty search_path in Autovacuum and non-psql/pgbench clients. 2018-02-26 07:39:47 -08:00
foreign Separate reinitialization of shared parallel-scan state from ExecReScan. 2017-08-30 13:18:16 -04:00
lib Rename rbtree.c functions to use "rbt" prefix not "rb" prefix. 2018-11-06 13:25:24 -05:00
libpq Fix up references to scram-sha-256 2018-01-30 17:05:35 -05:00
mb Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
nodes Revise attribute handling code on partition creation 2018-11-08 16:22:09 -03:00
optimizer Don't allow LIMIT/OFFSET clause within sub-selects to be pushed to workers. 2018-09-14 10:05:45 +05:30
parser Fix INSERT ON CONFLICT UPDATE through a view that isn't just SELECT *. 2018-08-04 19:38:58 -04:00
port Remove overzeleous assertions in pg_atomic_flag code. 2018-04-07 18:30:15 -07:00
portability Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postmaster Log when a BRIN autosummarization request fails 2018-03-14 12:00:53 -03:00
regex Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
replication Add subtransaction handling for table synchronization workers. 2018-07-16 17:55:13 -04:00
rewrite Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE. 2017-11-27 17:54:09 -05:00
snowball Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
statistics Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
storage PANIC on fsync() failure. 2018-11-19 13:40:57 +13:00
tcop Fix event triggers for partitioned tables 2018-10-06 19:17:46 -03:00
tsearch Fix serious performance problems in json(b) to_tsvector(). 2017-07-18 12:45:51 -04:00
utils Fix missing role dependencies for some schema and type ACLs. 2018-11-09 20:42:03 -05:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
fmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
funcapi.h Add a utility function to extract variadic function arguments 2017-10-25 07:14:21 -04:00
getaddrinfo.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
getopt_long.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
Makefile Add statistics subdirectory to Makefile. 2017-06-08 11:29:50 -04:00
miscadmin.h Backport: Mark assorted GUC variables as PGDLLIMPORT. 2018-02-22 12:54:45 -08:00
pg_config.h.in Fix detection of the result type of strerror_r(). 2018-09-30 16:24:56 -04:00
pg_config.h.win32 Stamp 10.6. 2018-11-05 16:45:50 -05:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix default minimum value for descending sequences 2017-01-23 14:00:58 -05:00
pg_getopt.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_trace.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pgstat.h Fix replication origin-related race conditions 2017-08-08 16:07:46 -04:00
pgtar.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
pgtime.h Mark assorted variables PGDLLIMPORT. 2017-12-05 09:24:05 -05:00
port.h Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
postgres.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
rusagestub.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
windowapi.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00