mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Don't export basebackup.c's sendTablespace().
Commit 72d422a5227ef6f76f412486a395aba9f53bf3f0 made xlog.c call sendTablespace() with the 'sizeonly' argument set to true, which required basebackup.c to export sendTablespace(). However, that's kind of ugly, so instead defer the call to sendTablespace() until basebackup.c regains control. That way, it can still be a static function. Patch by me, reviewed by Amit Kapila and Kyotaro Horiguchi. Discussion: http://postgr.es/m/CA+TgmoYq+59SJ2zBbP891ngWPA9fymOqntqYcweSDYXS2a620A@mail.gmail.com
This commit is contained in:
parent
a513f1dfbf
commit
1fa092913d
@ -10481,8 +10481,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno)
|
|||||||
XLogRecPtr
|
XLogRecPtr
|
||||||
do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
||||||
StringInfo labelfile, List **tablespaces,
|
StringInfo labelfile, List **tablespaces,
|
||||||
StringInfo tblspcmapfile, bool infotbssize,
|
StringInfo tblspcmapfile, bool needtblspcmapfile)
|
||||||
bool needtblspcmapfile)
|
|
||||||
{
|
{
|
||||||
bool exclusive = (labelfile == NULL);
|
bool exclusive = (labelfile == NULL);
|
||||||
bool backup_started_in_recovery = false;
|
bool backup_started_in_recovery = false;
|
||||||
@ -10702,14 +10701,6 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
|||||||
|
|
||||||
datadirpathlen = strlen(DataDir);
|
datadirpathlen = strlen(DataDir);
|
||||||
|
|
||||||
/*
|
|
||||||
* Report that we are now estimating the total backup size if we're
|
|
||||||
* streaming base backup as requested by pg_basebackup
|
|
||||||
*/
|
|
||||||
if (tablespaces)
|
|
||||||
pgstat_progress_update_param(PROGRESS_BASEBACKUP_PHASE,
|
|
||||||
PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE);
|
|
||||||
|
|
||||||
/* Collect information about all tablespaces */
|
/* Collect information about all tablespaces */
|
||||||
tblspcdir = AllocateDir("pg_tblspc");
|
tblspcdir = AllocateDir("pg_tblspc");
|
||||||
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
|
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
|
||||||
@ -10774,8 +10765,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
|
|||||||
ti->oid = pstrdup(de->d_name);
|
ti->oid = pstrdup(de->d_name);
|
||||||
ti->path = pstrdup(buflinkpath.data);
|
ti->path = pstrdup(buflinkpath.data);
|
||||||
ti->rpath = relpath ? pstrdup(relpath) : NULL;
|
ti->rpath = relpath ? pstrdup(relpath) : NULL;
|
||||||
ti->size = infotbssize ?
|
ti->size = -1;
|
||||||
sendTablespace(fullpath, ti->oid, true, NULL) : -1;
|
|
||||||
|
|
||||||
if (tablespaces)
|
if (tablespaces)
|
||||||
*tablespaces = lappend(*tablespaces, ti);
|
*tablespaces = lappend(*tablespaces, ti);
|
||||||
|
@ -76,7 +76,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
|||||||
if (exclusive)
|
if (exclusive)
|
||||||
{
|
{
|
||||||
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL,
|
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL,
|
||||||
NULL, NULL, false, true);
|
NULL, NULL, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
|||||||
register_persistent_abort_backup_handler();
|
register_persistent_abort_backup_handler();
|
||||||
|
|
||||||
startpoint = do_pg_start_backup(backupidstr, fast, NULL, label_file,
|
startpoint = do_pg_start_backup(backupidstr, fast, NULL, label_file,
|
||||||
NULL, tblspc_map_file, false, true);
|
NULL, tblspc_map_file, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_RETURN_LSN(startpoint);
|
PG_RETURN_LSN(startpoint);
|
||||||
|
@ -58,6 +58,8 @@ typedef struct
|
|||||||
pg_checksum_type manifest_checksum_type;
|
pg_checksum_type manifest_checksum_type;
|
||||||
} basebackup_options;
|
} basebackup_options;
|
||||||
|
|
||||||
|
static int64 sendTablespace(char *path, char *oid, bool sizeonly,
|
||||||
|
struct backup_manifest_info *manifest);
|
||||||
static int64 sendDir(const char *path, int basepathlen, bool sizeonly,
|
static int64 sendDir(const char *path, int basepathlen, bool sizeonly,
|
||||||
List *tablespaces, bool sendtblspclinks,
|
List *tablespaces, bool sendtblspclinks,
|
||||||
backup_manifest_info *manifest, const char *spcoid);
|
backup_manifest_info *manifest, const char *spcoid);
|
||||||
@ -307,8 +309,7 @@ perform_base_backup(basebackup_options *opt)
|
|||||||
PROGRESS_BASEBACKUP_PHASE_WAIT_CHECKPOINT);
|
PROGRESS_BASEBACKUP_PHASE_WAIT_CHECKPOINT);
|
||||||
startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &starttli,
|
startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &starttli,
|
||||||
labelfile, &tablespaces,
|
labelfile, &tablespaces,
|
||||||
tblspc_map_file,
|
tblspc_map_file, opt->sendtblspcmapfile);
|
||||||
opt->progress, opt->sendtblspcmapfile);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once do_pg_start_backup has been called, ensure that any failure causes
|
* Once do_pg_start_backup has been called, ensure that any failure causes
|
||||||
@ -337,9 +338,6 @@ perform_base_backup(basebackup_options *opt)
|
|||||||
|
|
||||||
/* Add a node for the base directory at the end */
|
/* Add a node for the base directory at the end */
|
||||||
ti = palloc0(sizeof(tablespaceinfo));
|
ti = palloc0(sizeof(tablespaceinfo));
|
||||||
if (opt->progress)
|
|
||||||
ti->size = sendDir(".", 1, true, tablespaces, true, NULL, NULL);
|
|
||||||
else
|
|
||||||
ti->size = -1;
|
ti->size = -1;
|
||||||
tablespaces = lappend(tablespaces, ti);
|
tablespaces = lappend(tablespaces, ti);
|
||||||
|
|
||||||
@ -349,10 +347,19 @@ perform_base_backup(basebackup_options *opt)
|
|||||||
*/
|
*/
|
||||||
if (opt->progress)
|
if (opt->progress)
|
||||||
{
|
{
|
||||||
|
pgstat_progress_update_param(PROGRESS_BASEBACKUP_PHASE,
|
||||||
|
PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE);
|
||||||
|
|
||||||
foreach(lc, tablespaces)
|
foreach(lc, tablespaces)
|
||||||
{
|
{
|
||||||
tablespaceinfo *tmp = (tablespaceinfo *) lfirst(lc);
|
tablespaceinfo *tmp = (tablespaceinfo *) lfirst(lc);
|
||||||
|
|
||||||
|
if (tmp->path == NULL)
|
||||||
|
tmp->size = sendDir(".", 1, true, tablespaces, true, NULL,
|
||||||
|
NULL);
|
||||||
|
else
|
||||||
|
tmp->size = sendTablespace(tmp->path, tmp->oid, true,
|
||||||
|
NULL);
|
||||||
backup_total += tmp->size;
|
backup_total += tmp->size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1145,7 +1152,7 @@ sendFileWithContent(const char *filename, const char *content,
|
|||||||
*
|
*
|
||||||
* Only used to send auxiliary tablespaces, not PGDATA.
|
* Only used to send auxiliary tablespaces, not PGDATA.
|
||||||
*/
|
*/
|
||||||
int64
|
static int64
|
||||||
sendTablespace(char *path, char *spcoid, bool sizeonly,
|
sendTablespace(char *path, char *spcoid, bool sizeonly,
|
||||||
backup_manifest_info *manifest)
|
backup_manifest_info *manifest)
|
||||||
{
|
{
|
||||||
|
@ -372,7 +372,7 @@ typedef enum SessionBackupState
|
|||||||
|
|
||||||
extern XLogRecPtr do_pg_start_backup(const char *backupidstr, bool fast,
|
extern XLogRecPtr do_pg_start_backup(const char *backupidstr, bool fast,
|
||||||
TimeLineID *starttli_p, StringInfo labelfile,
|
TimeLineID *starttli_p, StringInfo labelfile,
|
||||||
List **tablespaces, StringInfo tblspcmapfile, bool infotbssize,
|
List **tablespaces, StringInfo tblspcmapfile,
|
||||||
bool needtblspcmapfile);
|
bool needtblspcmapfile);
|
||||||
extern XLogRecPtr do_pg_stop_backup(char *labelfile, bool waitforarchive,
|
extern XLogRecPtr do_pg_stop_backup(char *labelfile, bool waitforarchive,
|
||||||
TimeLineID *stoptli_p);
|
TimeLineID *stoptli_p);
|
||||||
|
@ -14,9 +14,6 @@
|
|||||||
|
|
||||||
#include "nodes/replnodes.h"
|
#include "nodes/replnodes.h"
|
||||||
|
|
||||||
struct backup_manifest_info; /* avoid including backup_manifest.h */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Minimum and maximum values of MAX_RATE option in BASE_BACKUP command.
|
* Minimum and maximum values of MAX_RATE option in BASE_BACKUP command.
|
||||||
*/
|
*/
|
||||||
@ -33,7 +30,4 @@ typedef struct
|
|||||||
|
|
||||||
extern void SendBaseBackup(BaseBackupCmd *cmd);
|
extern void SendBaseBackup(BaseBackupCmd *cmd);
|
||||||
|
|
||||||
extern int64 sendTablespace(char *path, char *oid, bool sizeonly,
|
|
||||||
struct backup_manifest_info *manifest);
|
|
||||||
|
|
||||||
#endif /* _BASEBACKUP_H */
|
#endif /* _BASEBACKUP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user