pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Introduce durable_rename() and durable_link_or_rename(). 6+ messages / 1 participants [nested] [flat]
* pgsql: Introduce durable_rename() and durable_link_or_rename(). @ 2016-03-10 03:25 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2016-03-10 03:25 UTC (permalink / raw) To: pgsql-committers 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 Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/606e0f9841b820d826f837bf741a3e5e9cc62fa1 Modified Files -------------- src/backend/replication/logical/origin.c | 2 +- src/backend/replication/slot.c | 2 +- src/backend/storage/file/fd.c | 257 +++++++++++++++++++++++++------ src/backend/storage/file/reinit.c | 2 +- src/include/storage/fd.h | 4 +- 5 files changed, 215 insertions(+), 52 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Introduce durable_rename() and durable_link_or_rename(). @ 2016-03-10 03:25 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2016-03-10 03:25 UTC (permalink / raw) To: pgsql-committers 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 Branch ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/63b06e8fa6bce0e92b9209531757a2ba5393802d Modified Files -------------- src/backend/replication/logical/origin.c | 2 +- src/backend/replication/slot.c | 2 +- src/backend/storage/file/fd.c | 257 +++++++++++++++++++++++++------ src/backend/storage/file/reinit.c | 2 +- src/include/storage/fd.h | 4 +- 5 files changed, 215 insertions(+), 52 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Introduce durable_rename() and durable_link_or_rename(). @ 2016-03-10 03:25 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2016-03-10 03:25 UTC (permalink / raw) To: pgsql-committers 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 Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/43b491a817fb494bef22c9e8374a9fddfd30ebda Modified Files -------------- src/backend/replication/slot.c | 2 +- src/backend/storage/file/fd.c | 257 +++++++++++++++++++++++++++++++------- src/backend/storage/file/reinit.c | 2 +- src/include/storage/fd.h | 4 +- 4 files changed, 214 insertions(+), 51 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Introduce durable_rename() and durable_link_or_rename(). @ 2016-03-10 03:25 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2016-03-10 03:25 UTC (permalink / raw) To: pgsql-committers 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 Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/e069848a3966bf64b4f4dc24d66a353d50878312 Modified Files -------------- src/backend/storage/file/fd.c | 257 +++++++++++++++++++++++++++++++------- src/backend/storage/file/reinit.c | 2 +- src/include/storage/fd.h | 4 +- 3 files changed, 213 insertions(+), 50 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Introduce durable_rename() and durable_link_or_rename(). @ 2016-03-10 03:25 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2016-03-10 03:25 UTC (permalink / raw) To: pgsql-committers 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 Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/c224d44f77247a2eb8ce43fcaeb519f214c1b7d1 Modified Files -------------- src/backend/storage/file/fd.c | 255 +++++++++++++++++++++++++++++++------- src/backend/storage/file/reinit.c | 2 +- src/include/storage/fd.h | 4 +- 3 files changed, 211 insertions(+), 50 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Introduce durable_rename() and durable_link_or_rename(). @ 2016-03-10 03:25 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 6+ messages in thread From: Andres Freund @ 2016-03-10 03:25 UTC (permalink / raw) To: pgsql-committers 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 Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/d0e47bcd47bcfa4a3be020965c93980f5fad6e80 Modified Files -------------- src/backend/storage/file/fd.c | 255 +++++++++++++++++++++++++++++++------- src/backend/storage/file/reinit.c | 2 +- src/include/storage/fd.h | 4 +- 3 files changed, 211 insertions(+), 50 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2016-03-10 03:25 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-03-10 03:25 pgsql: Introduce durable_rename() and durable_link_or_rename(). Andres Freund <andres@anarazel.de> 2016-03-10 03:25 pgsql: Introduce durable_rename() and durable_link_or_rename(). Andres Freund <andres@anarazel.de> 2016-03-10 03:25 pgsql: Introduce durable_rename() and durable_link_or_rename(). Andres Freund <andres@anarazel.de> 2016-03-10 03:25 pgsql: Introduce durable_rename() and durable_link_or_rename(). Andres Freund <andres@anarazel.de> 2016-03-10 03:25 pgsql: Introduce durable_rename() and durable_link_or_rename(). Andres Freund <andres@anarazel.de> 2016-03-10 03:25 pgsql: Introduce durable_rename() and durable_link_or_rename(). Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox