postgresql/src/include
Andres Freund d0e47bcd47 Introduce durable_rename() and durable_link_or_rename().
Renaming a file using rename(2) is not guaranteed to be durable in face
of crashes; especially on filesystems like xfs and ext4 when mounted
with data=writeback. To be certain that a rename() atomically replaces
the previous file contents in the face of crashes and different
filesystems, one has to fsync the old filename, rename the file, fsync
the new filename, fsync the containing directory.  This sequence is not
generally adhered to currently; which exposes us to data loss risks. To
avoid having to repeat this arduous sequence, introduce
durable_rename(), which wraps all that.

Also add durable_link_or_rename(). Several places use link() (with a
fallback to rename()) to rename a file, trying to avoid replacing the
target file out of paranoia. Some of those rename sequences need to be
durable as well. There seems little reason extend several copies of the
same logic, so centralize the link() callers.

This commit does not yet make use of the new functions; they're used in
a followup commit.

Author: Michael Paquier, Andres Freund
Discussion: 56583BDD.9060302@2ndquadrant.com
Backpatch: All supported branches
2016-03-09 18:53:54 -08:00
..
access Remove files signaling a standby promotion request at postmaster startup 2015-09-09 23:03:17 +09:00
bootstrap Fix off-by-one loop count in MapArrayTypeName, and get rid of static array. 2014-12-16 15:35:46 -05:00
catalog Clean up some lack-of-STRICT issues in the core code, too. 2016-01-09 16:58:33 -05:00
commands Rework internals of changing a type's ownership 2015-12-21 19:49:15 -03:00
executor Avoid leaking memory while evaluating arguments for a table function. 2014-06-19 22:13:54 -04:00
foreign pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
lib Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
libpq Remove code to match IPv4 pg_hba.conf entries to IPv4-in-IPv6 addresses. 2015-02-17 12:49:46 -05:00
mb Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
nodes Avoid leaking memory while evaluating arguments for a table function. 2014-06-19 22:13:54 -04:00
optimizer Fix generation of MergeAppend plans for optimized min/max on expressions. 2013-11-07 13:13:47 -05:00
parser Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
port Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
portability Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
postmaster Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
regex Suppress compiler warnings about useless comparison of unsigned to zero. 2016-02-15 17:11:52 -05:00
replication Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
rewrite Avoid getting more than AccessShareLock when deparsing a query. 2014-03-06 19:31:16 -05:00
snowball Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
storage Introduce durable_rename() and durable_link_or_rename(). 2016-03-09 18:53:54 -08:00
tcop Be more careful to not lose sync in the FE/BE protocol. 2015-02-02 17:09:31 +02:00
tsearch Predict integer overflow to avoid buffer overruns. 2014-02-17 09:33:37 -05:00
utils Fix subtransaction cleanup after an outer-subtransaction portal fails. 2015-09-04 13:36:50 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
c.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
fmgr.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
funcapi.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
getaddrinfo.h Fix assorted issues in client host name lookup. 2014-04-02 17:11:34 -04:00
getopt_long.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Makefile Fix server header file installation with vpath builds 2011-11-10 20:54:50 +02:00
miscadmin.h Perform an immediate shutdown if the postmaster.pid file is removed. 2015-10-06 17:15:27 -04:00
pg_config.h.in Cope with Readline's failure to track SIGWINCH events outside of input. 2015-12-16 16:58:56 -05:00
pg_config.h.win32 Stamp 9.1.20. 2016-02-08 16:21:40 -05:00
pg_config_manual.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
pg_trace.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
pgstat.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
pgtar.h Adopt the GNU convention for handling tar-archive members exceeding 8GB. 2015-11-21 20:21:32 -05:00
pgtime.h Support timezone abbreviations that sometimes change. 2014-10-16 15:22:23 -04:00
port.h Revert error-throwing wrappers for the printf family of functions. 2015-05-19 18:18:16 -04:00
postgres.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
postgres_ext.h Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
postgres_fe.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
rusagestub.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
windowapi.h Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00