aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/clog.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/clog.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/clog.c')
-rw-r--r--src/backend/access/transam/clog.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 2d335109303..7a007a6ba50 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -577,6 +577,13 @@ ShutdownCLOG(void)
/* Flush dirty CLOG pages to disk */
TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(false);
SimpleLruFlush(ClogCtl, false);
+
+ /*
+ * fsync pg_xact to ensure that any files flushed previously are durably
+ * on disk.
+ */
+ fsync_fname("pg_xact", true);
+
TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(false);
}
@@ -589,6 +596,13 @@ CheckPointCLOG(void)
/* Flush dirty CLOG pages to disk */
TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(true);
SimpleLruFlush(ClogCtl, true);
+
+ /*
+ * fsync pg_xact to ensure that any files flushed previously are durably
+ * on disk.
+ */
+ fsync_fname("pg_xact", true);
+
TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(true);
}