diff options
author | Andres Freund <andres@anarazel.de> | 2022-01-23 13:59:23 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2022-01-23 14:09:27 -0800 |
commit | 9c86d9337eb0b9fdf7a8ce19d6044cc7ca0086fb (patch) | |
tree | 036df91b4d925e429b911d6b7618e5849ecd6cfa /src/bin/pg_basebackup/pg_basebackup.c | |
parent | ac7df108cf32e11e4bd120898ed09bd58fa5b62c (diff) |
pg_basebackup: Skip a few more fsyncs if --no-sync is specified.
This is mostly interesting for running the regression tests on machines with
slow / overloaded IO.
Discussion: https://postgr.es/m/20220119041646.rhuo3youiqxqjmo2@alap3.anarazel.de
Diffstat (limited to 'src/bin/pg_basebackup/pg_basebackup.c')
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 7a56ebb2c92..221cc4caf23 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -2201,9 +2201,21 @@ BaseBackup(void) snprintf(tmp_filename, MAXPGPATH, "%s/backup_manifest.tmp", basedir); snprintf(filename, MAXPGPATH, "%s/backup_manifest", basedir); - /* durable_rename emits its own log message in case of failure */ - if (durable_rename(tmp_filename, filename) != 0) - exit(1); + if (do_sync) + { + /* durable_rename emits its own log message in case of failure */ + if (durable_rename(tmp_filename, filename) != 0) + exit(1); + } + else + { + if (rename(tmp_filename, filename) != 0) + { + pg_log_error("could not rename file \"%s\" to \"%s\": %m", + tmp_filename, filename); + exit(1); + } + } } if (verbose) |