mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
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
This commit is contained in:
@ -10206,7 +10206,7 @@ XLogFileNameP(TimeLineID tli, XLogSegNo segno)
|
||||
*/
|
||||
XLogRecPtr
|
||||
do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
||||
StringInfo labelfile, DIR *tblspcdir, List **tablespaces,
|
||||
StringInfo labelfile, List **tablespaces,
|
||||
StringInfo tblspcmapfile, bool infotbssize,
|
||||
bool needtblspcmapfile)
|
||||
{
|
||||
@ -10297,6 +10297,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
||||
PG_ENSURE_ERROR_CLEANUP(pg_start_backup_callback, (Datum) BoolGetDatum(exclusive));
|
||||
{
|
||||
bool gotUniqueStartpoint = false;
|
||||
DIR *tblspcdir;
|
||||
struct dirent *de;
|
||||
tablespaceinfo *ti;
|
||||
int datadirpathlen;
|
||||
@ -10428,6 +10429,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
||||
datadirpathlen = strlen(DataDir);
|
||||
|
||||
/* Collect information about all tablespaces */
|
||||
tblspcdir = AllocateDir("pg_tblspc");
|
||||
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
|
||||
{
|
||||
char fullpath[MAXPGPATH + 10];
|
||||
@ -10476,7 +10478,6 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
||||
appendStringInfoChar(&buflinkpath, *s++);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Relpath holds the relative path of the tablespace directory
|
||||
* when it's located within PGDATA, or NULL if it's located
|
||||
@ -10511,6 +10512,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
||||
errmsg("tablespaces are not supported on this platform")));
|
||||
#endif
|
||||
}
|
||||
FreeDir(tblspcdir);
|
||||
|
||||
/*
|
||||
* Construct backup label file
|
||||
|
Reference in New Issue
Block a user