diff options
author | Michael Paquier <michael@paquier.xyz> | 2018-09-14 10:04:14 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2018-09-14 10:04:14 +0900 |
commit | 0ba06e0bfb8cfd24ff17aca92aa72245ddd6c4d7 (patch) | |
tree | 4c4f1402ee522850efa1487a9fe117d6419ff138 /src/common/file_utils.c | |
parent | 28a8fa984c63fd525ab03c469f293e957619654b (diff) | |
download | postgresql-0ba06e0bfb8cfd24ff17aca92aa72245ddd6c4d7.tar.gz postgresql-0ba06e0bfb8cfd24ff17aca92aa72245ddd6c4d7.zip |
Allow concurrent-safe open() and fopen() in frontend code for Windows
PostgreSQL uses a custom wrapper for open() and fopen() which is
concurrent-safe, allowing multiple processes to open and work on the
same file. This has a couple of advantages:
- pg_test_fsync does not handle O_DSYNC correctly otherwise, leading to
false claims that disks are unsafe.
- TAP tests can run into race conditions when a postmaster and pg_ctl
open postmaster.pid, fixing some random failures in the buildfam.
pg_upgrade is one frontend tool using workarounds to bypass file locking
issues with the log files it generates, however the interactions with
pg_ctl are proving to be tedious to get rid of, so this is left for
later.
Author: Laurenz Albe
Reviewed-by: Michael Paquier, Kuntal Ghosh
Discussion: https://postgr.es/m/1527846213.2475.31.camel@cybertec.at
Discussion: https://postgr.es/m/16922.1520722108@sss.pgh.pa.us
Diffstat (limited to 'src/common/file_utils.c')
-rw-r--r-- | src/common/file_utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/file_utils.c b/src/common/file_utils.c index 48876061c38..d952bc8c882 100644 --- a/src/common/file_utils.c +++ b/src/common/file_utils.c @@ -222,7 +222,7 @@ pre_sync_fname(const char *fname, bool isdir, const char *progname) { int fd; - fd = open(fname, O_RDONLY | PG_BINARY); + fd = open(fname, O_RDONLY | PG_BINARY, 0); if (fd < 0) { @@ -283,7 +283,7 @@ fsync_fname(const char *fname, bool isdir, const char *progname) * unsupported operations, e.g. opening a directory under Windows), and * logging others. */ - fd = open(fname, flags); + fd = open(fname, flags, 0); if (fd < 0) { if (errno == EACCES || (isdir && errno == EISDIR)) |