1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

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
This commit is contained in:
Teodor Sigaev
2017-03-27 19:33:01 +03:00
parent 1f171a1803
commit 1b02be21f2
6 changed files with 78 additions and 13 deletions

View File

@ -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);
}
/*