Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c86d93

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 withslow / overloaded IO.Discussion:https://postgr.es/m/20220119041646.rhuo3youiqxqjmo2@alap3.anarazel.de
1 parentac7df10 commit9c86d93

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
elseif (method==CLOSE_UNLINK)
451461
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp