diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-12-04 18:37:54 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-12-04 18:37:54 -0500 |
commit | 066bc21c0e085e2642ff25cc665c4efad3669d6f (patch) | |
tree | 027c786114bb35dad2ad7bb4af9aea5736963824 /src/backend/replication/basebackup.c | |
parent | 561885db05d3296082ce8750805b8ec322cf9aa1 (diff) | |
download | postgresql-066bc21c0e085e2642ff25cc665c4efad3669d6f.tar.gz postgresql-066bc21c0e085e2642ff25cc665c4efad3669d6f.zip |
Simplify do_pg_start_backup's API by opening pg_tblspc internally.
do_pg_start_backup() expects its callers to pass in an open DIR pointer
for the pg_tblspc directory, but there's no apparent advantage in that.
It complicates the callers without adding any flexibility, and there's no
robustness advantage, since we surely have to be prepared for errors during
the scan of pg_tblspc anyway. In fact, by holding an extra kernel resource
during operations like the preliminary checkpoint, we might be making
things a fraction more failure-prone not less. Hence, remove that argument
and open the directory just for the duration of the actual scan.
Discussion: https://postgr.es/m/28752.1512413887@sss.pgh.pa.us
Diffstat (limited to 'src/backend/replication/basebackup.c')
-rw-r--r-- | src/backend/replication/basebackup.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index b264b69aef6..cd7d391b2ff 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -64,7 +64,7 @@ static int64 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *sta static void send_int8_string(StringInfoData *buf, int64 intval); static void SendBackupHeader(List *tablespaces); static void base_backup_cleanup(int code, Datum arg); -static void perform_base_backup(basebackup_options *opt, DIR *tblspcdir); +static void perform_base_backup(basebackup_options *opt); static void parse_basebackup_options(List *options, basebackup_options *opt); static void SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli); static int compareWalFileNames(const void *a, const void *b); @@ -188,7 +188,7 @@ base_backup_cleanup(int code, Datum arg) * clobbered by longjmp" from stupider versions of gcc. */ static void -perform_base_backup(basebackup_options *opt, DIR *tblspcdir) +perform_base_backup(basebackup_options *opt) { XLogRecPtr startptr; TimeLineID starttli; @@ -207,7 +207,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir) tblspc_map_file = makeStringInfo(); startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &starttli, - labelfile, tblspcdir, &tablespaces, + labelfile, &tablespaces, tblspc_map_file, opt->progress, opt->sendtblspcmapfile); @@ -690,7 +690,6 @@ parse_basebackup_options(List *options, basebackup_options *opt) void SendBaseBackup(BaseBackupCmd *cmd) { - DIR *dir; basebackup_options opt; parse_basebackup_options(cmd->options, &opt); @@ -706,17 +705,7 @@ SendBaseBackup(BaseBackupCmd *cmd) set_ps_display(activitymsg, false); } - /* Make sure we can open the directory with tablespaces in it */ - dir = AllocateDir("pg_tblspc"); - if (!dir) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not open directory \"%s\": %m", - "pg_tblspc"))); - - perform_base_backup(&opt, dir); - - FreeDir(dir); + perform_base_backup(&opt); } static void |