aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.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/xlog.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/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 58790e0e96e..61ca81d1d24 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3475,7 +3475,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
if (!find_free)
{
/* Force installation: get rid of any pre-existing segment file */
- unlink(path);
+ durable_unlink(path, DEBUG1);
}
else
{
@@ -4026,16 +4026,13 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
path)));
return;
}
- rc = unlink(newpath);
+ rc = durable_unlink(newpath, LOG);
#else
- rc = unlink(path);
+ rc = durable_unlink(path, LOG);
#endif
if (rc != 0)
{
- ereport(LOG,
- (errcode_for_file_access(),
- errmsg("could not remove old transaction log file \"%s\": %m",
- path)));
+ /* Message already logged by durable_unlink() */
return;
}
CheckpointStats.ckpt_segs_removed++;
@@ -10771,17 +10768,13 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
(errcode_for_file_access(),
errmsg("could not read file \"%s\": %m",
BACKUP_LABEL_FILE)));
- if (unlink(BACKUP_LABEL_FILE) != 0)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not remove file \"%s\": %m",
- BACKUP_LABEL_FILE)));
+ durable_unlink(BACKUP_LABEL_FILE, ERROR);
/*
* Remove tablespace_map file if present, it is created only if there
* are tablespaces.
*/
- unlink(TABLESPACE_MAP);
+ durable_unlink(TABLESPACE_MAP, DEBUG1);
}
PG_END_ENSURE_ERROR_CLEANUP(pg_stop_backup_callback, (Datum) BoolGetDatum(exclusive));
}