aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/walmethods.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-01-23 13:59:23 -0800
committerAndres Freund <andres@anarazel.de>2022-01-23 14:09:27 -0800
commit9c86d9337eb0b9fdf7a8ce19d6044cc7ca0086fb (patch)
tree036df91b4d925e429b911d6b7618e5849ecd6cfa /src/bin/pg_basebackup/walmethods.c
parentac7df108cf32e11e4bd120898ed09bd58fa5b62c (diff)
downloadpostgresql-9c86d9337eb0b9fdf7a8ce19d6044cc7ca0086fb.tar.gz
postgresql-9c86d9337eb0b9fdf7a8ce19d6044cc7ca0086fb.zip
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/walmethods.c')
-rw-r--r--src/bin/pg_basebackup/walmethods.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
index f74bd13315c..a6d08c1270a 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -445,7 +445,17 @@ dir_close(Walfile f, WalCloseMethod method)
snprintf(tmppath2, sizeof(tmppath2), "%s/%s",
dir_data->basedir, filename2);
pg_free(filename2);
- r = durable_rename(tmppath, tmppath2);
+ if (dir_data->sync)
+ r = durable_rename(tmppath, tmppath2);
+ else
+ {
+ if (rename(tmppath, tmppath2) != 0)
+ {
+ pg_log_error("could not rename file \"%s\" to \"%s\": %m",
+ tmppath, tmppath2);
+ r = -1;
+ }
+ }
}
else if (method == CLOSE_UNLINK)
{