aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/commit_ts.c
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2017-03-27 19:33:01 +0300
committerTeodor Sigaev <teodor@sigaev.ru>2017-03-27 19:33:01 +0300
commit1b02be21f271db6bd3cd43abb23fa596fcb6bac3 (patch)
tree1052877089af6b9cf2c8cc4f91d365147de40575 /src/backend/access/transam/commit_ts.c
parent1f171a1803c28d3ae24636c9ca3352ec82c39e5f (diff)
downloadpostgresql-1b02be21f271db6bd3cd43abb23fa596fcb6bac3.tar.gz
postgresql-1b02be21f271db6bd3cd43abb23fa596fcb6bac3.zip
Fsync directory after creating or unlinking file.
If file was created/deleted just before powerloss it's possible that file system will miss that. To prevent it, call fsync() where creating/ unlinkg file is critical. Author: Michael Paquier Reviewed-by: Ashutosh Bapat, Takayuki Tsunakawa, me
Diffstat (limited to 'src/backend/access/transam/commit_ts.c')
-rw-r--r--src/backend/access/transam/commit_ts.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 8e1df6e0eab..03ffa209084 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -746,6 +746,12 @@ ShutdownCommitTs(void)
{
/* Flush dirty CommitTs pages to disk */
SimpleLruFlush(CommitTsCtl, false);
+
+ /*
+ * fsync pg_commit_ts to ensure that any files flushed previously are durably
+ * on disk.
+ */
+ fsync_fname("pg_commit_ts", true);
}
/*
@@ -756,6 +762,12 @@ CheckPointCommitTs(void)
{
/* Flush dirty CommitTs pages to disk */
SimpleLruFlush(CommitTsCtl, true);
+
+ /*
+ * fsync pg_commit_ts to ensure that any files flushed previously are durably
+ * on disk.
+ */
+ fsync_fname("pg_commit_ts", true);
}
/*