Skip to content

Commit 9c86d93

Browse files
committed
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
1 parent ac7df10 commit 9c86d93

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,9 +2201,21 @@ BaseBackup(void)
22012201
snprintf(tmp_filename, MAXPGPATH, "%s/backup_manifest.tmp", basedir);
22022202
snprintf(filename, MAXPGPATH, "%s/backup_manifest", basedir);
22032203

2204-
/* durable_rename emits its own log message in case of failure */
2205-
if (durable_rename(tmp_filename, filename) != 0)
2206-
exit(1);
2204+
if (do_sync)
2205+
{
2206+
/* durable_rename emits its own log message in case of failure */
2207+
if (durable_rename(tmp_filename, filename) != 0)
2208+
exit(1);
2209+
}
2210+
else
2211+
{
2212+
if (rename(tmp_filename, filename) != 0)
2213+
{
2214+
pg_log_error("could not rename file \"%s\" to \"%s\": %m",
2215+
tmp_filename, filename);
2216+
exit(1);
2217+
}
2218+
}
22072219
}
22082220

22092221
if (verbose)

src/bin/pg_basebackup/walmethods.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,17 @@ dir_close(Walfile f, WalCloseMethod method)
445445
snprintf(tmppath2, sizeof(tmppath2), "%s/%s",
446446
dir_data->basedir, filename2);
447447
pg_free(filename2);
448-
r = durable_rename(tmppath, tmppath2);
448+
if (dir_data->sync)
449+
r = durable_rename(tmppath, tmppath2);
450+
else
451+
{
452+
if (rename(tmppath, tmppath2) != 0)
453+
{
454+
pg_log_error("could not rename file \"%s\" to \"%s\": %m",
455+
tmppath, tmppath2);
456+
r = -1;
457+
}
458+
}
449459
}
450460
else if (method == CLOSE_UNLINK)
451461
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy