diff options
author | Thomas Munro <tmunro@postgresql.org> | 2018-11-19 13:31:10 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2018-11-19 17:41:26 +1300 |
commit | 9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1 (patch) | |
tree | aac67e1a7976dcad55e7dce5574412b7f5048381 /doc/src | |
parent | 1556cb2fc5c774c3f7390dd6fb19190ee0c73f8b (diff) | |
download | postgresql-9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1.tar.gz postgresql-9ccdd7f66e3324d2b6d3dec282cfa9ff084083f1.zip |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 0f8f2ef920d..c4effa034c1 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -8161,6 +8161,38 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' </listitem> </varlistentry> + <varlistentry id="guc-data-sync-retry" xreflabel="data_sync_retry"> + <term><varname>data_sync_retry</varname> (<type>boolean</type>) + <indexterm> + <primary><varname>data_sync_retry</varname> configuration parameter</primary> + </indexterm> + </term> + <listitem> + <para> + When set to false, which is the default, <productname>PostgreSQL</productname> + will raise a PANIC-level error on failure to flush modified data files + to the filesystem. This causes the database server to crash. + </para> + <para> + On some operating systems, the status of data in the kernel's page + cache is unknown after a write-back failure. In some cases it might + have been entirely forgotten, making it unsafe to retry; the second + attempt may be reported as successful, when in fact the data has been + lost. In these circumstances, the only way to avoid data loss is to + recover from the WAL after any failure is reported, preferably + after investigating the root cause of the failure and replacing any + faulty hardware. + </para> + <para> + If set to true, <productname>PostgreSQL</productname> will instead + report an error but continue to run so that the data flushing + operation can be retried in a later checkpoint. Only set it to true + after investigating the operating system's treatment of buffered data + in case of write-back failure. + </para> + </listitem> + </varlistentry> + </variablelist> </sect1> |