Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1fa0929

Browse files
committed
Don't export basebackup.c's sendTablespace().
Commit 72d422a 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
1 parent a513f1d commit 1fa0929

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10481,8 +10481,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno)
1048110481
XLogRecPtr
1048210482
do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
1048310483
StringInfo labelfile, List **tablespaces,
10484-
StringInfo tblspcmapfile, bool infotbssize,
10485-
bool needtblspcmapfile)
10484+
StringInfo tblspcmapfile, bool needtblspcmapfile)
1048610485
{
1048710486
bool exclusive = (labelfile == NULL);
1048810487
bool backup_started_in_recovery = false;
@@ -10702,14 +10701,6 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
1070210701

1070310702
datadirpathlen = strlen(DataDir);
1070410703

10705-
/*
10706-
* Report that we are now estimating the total backup size if we're
10707-
* streaming base backup as requested by pg_basebackup
10708-
*/
10709-
if (tablespaces)
10710-
pgstat_progress_update_param(PROGRESS_BASEBACKUP_PHASE,
10711-
PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE);
10712-
1071310704
/* Collect information about all tablespaces */
1071410705
tblspcdir = AllocateDir("pg_tblspc");
1071510706
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
@@ -10774,8 +10765,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
1077410765
ti->oid = pstrdup(de->d_name);
1077510766
ti->path = pstrdup(buflinkpath.data);
1077610767
ti->rpath = relpath ? pstrdup(relpath) : NULL;
10777-
ti->size = infotbssize ?
10778-
sendTablespace(fullpath, ti->oid, true, NULL) : -1;
10768+
ti->size = -1;
1077910769

1078010770
if (tablespaces)
1078110771
*tablespaces = lappend(*tablespaces, ti);

src/backend/access/transam/xlogfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
7676
if (exclusive)
7777
{
7878
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL,
79-
NULL, NULL, false, true);
79+
NULL, NULL, true);
8080
}
8181
else
8282
{
@@ -94,7 +94,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
9494
register_persistent_abort_backup_handler();
9595

9696
startpoint = do_pg_start_backup(backupidstr, fast, NULL, label_file,
97-
NULL, tblspc_map_file, false, true);
97+
NULL, tblspc_map_file, true);
9898
}
9999

100100
PG_RETURN_LSN(startpoint);

src/backend/replication/basebackup.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ typedef struct
5858
pg_checksum_type manifest_checksum_type;
5959
} basebackup_options;
6060

61+
static int64 sendTablespace(char *path, char *oid, bool sizeonly,
62+
struct backup_manifest_info *manifest);
6163
static int64 sendDir(const char *path, int basepathlen, bool sizeonly,
6264
List *tablespaces, bool sendtblspclinks,
6365
backup_manifest_info *manifest, const char *spcoid);
@@ -307,8 +309,7 @@ perform_base_backup(basebackup_options *opt)
307309
PROGRESS_BASEBACKUP_PHASE_WAIT_CHECKPOINT);
308310
startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &starttli,
309311
labelfile, &tablespaces,
310-
tblspc_map_file,
311-
opt->progress, opt->sendtblspcmapfile);
312+
tblspc_map_file, opt->sendtblspcmapfile);
312313

313314
/*
314315
* Once do_pg_start_backup has been called, ensure that any failure causes
@@ -337,10 +338,7 @@ perform_base_backup(basebackup_options *opt)
337338

338339
/* Add a node for the base directory at the end */
339340
ti = palloc0(sizeof(tablespaceinfo));
340-
if (opt->progress)
341-
ti->size = sendDir(".", 1, true, tablespaces, true, NULL, NULL);
342-
else
343-
ti->size = -1;
341+
ti->size = -1;
344342
tablespaces = lappend(tablespaces, ti);
345343

346344
/*
@@ -349,10 +347,19 @@ perform_base_backup(basebackup_options *opt)
349347
*/
350348
if (opt->progress)
351349
{
350+
pgstat_progress_update_param(PROGRESS_BASEBACKUP_PHASE,
351+
PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE);
352+
352353
foreach(lc, tablespaces)
353354
{
354355
tablespaceinfo *tmp = (tablespaceinfo *) lfirst(lc);
355356

357+
if (tmp->path == NULL)
358+
tmp->size = sendDir(".", 1, true, tablespaces, true, NULL,
359+
NULL);
360+
else
361+
tmp->size = sendTablespace(tmp->path, tmp->oid, true,
362+
NULL);
356363
backup_total += tmp->size;
357364
}
358365
}
@@ -1145,7 +1152,7 @@ sendFileWithContent(const char *filename, const char *content,
11451152
*
11461153
* Only used to send auxiliary tablespaces, not PGDATA.
11471154
*/
1148-
int64
1155+
static int64
11491156
sendTablespace(char *path, char *spcoid, bool sizeonly,
11501157
backup_manifest_info *manifest)
11511158
{

src/include/access/xlog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ typedef enum SessionBackupState
372372

373373
extern XLogRecPtr do_pg_start_backup(const char *backupidstr, bool fast,
374374
TimeLineID *starttli_p, StringInfo labelfile,
375-
List **tablespaces, StringInfo tblspcmapfile, bool infotbssize,
375+
List **tablespaces, StringInfo tblspcmapfile,
376376
bool needtblspcmapfile);
377377
extern XLogRecPtr do_pg_stop_backup(char *labelfile, bool waitforarchive,
378378
TimeLineID *stoptli_p);

src/include/replication/basebackup.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
#include "nodes/replnodes.h"
1616

17-
struct backup_manifest_info; /* avoid including backup_manifest.h */
18-
19-
2017
/*
2118
* Minimum and maximum values of MAX_RATE option in BASE_BACKUP command.
2219
*/
@@ -33,7 +30,4 @@ typedef struct
3330

3431
extern void SendBaseBackup(BaseBackupCmd *cmd);
3532

36-
extern int64 sendTablespace(char *path, char *oid, bool sizeonly,
37-
struct backup_manifest_info *manifest);
38-
3933
#endif /* _BASEBACKUP_H */

0 commit comments

Comments
 (0)