diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2017-03-27 19:33:01 +0300 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2017-03-27 19:33:01 +0300 |
commit | 1b02be21f271db6bd3cd43abb23fa596fcb6bac3 (patch) | |
tree | 1052877089af6b9cf2c8cc4f91d365147de40575 /src/backend/access/transam/commit_ts.c | |
parent | 1f171a1803c28d3ae24636c9ca3352ec82c39e5f (diff) | |
download | postgresql-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.c | 12 |
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); } /* |