From e65497df8f85ab9b9084c928ff69f384ea729b24 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Tue, 3 Mar 2020 12:03:43 +0900 Subject: Report progress of streaming base backup. This commit adds pg_stat_progress_basebackup view that reports the progress while an application like pg_basebackup is taking a base backup. This uses the progress reporting infrastructure added by c16dc1aca5e0, adding support for streaming base backup. Bump catversion. Author: Fujii Masao Reviewed-by: Kyotaro Horiguchi, Amit Langote, Sergei Kornilov Discussion: https://postgr.es/m/9ed8b801-8215-1f3d-62d7-65bff53f6e94@oss.nttdata.com --- src/backend/access/transam/xlog.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d19408b3be3..43615688824 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -39,6 +39,7 @@ #include "catalog/catversion.h" #include "catalog/pg_control.h" #include "catalog/pg_database.h" +#include "commands/progress.h" #include "commands/tablespace.h" #include "common/controldata_utils.h" #include "miscadmin.h" @@ -10228,6 +10229,10 @@ issue_xlog_fsync(int fd, XLogSegNo segno) * active at the same time, and they don't conflict with an exclusive backup * either. * + * tablespaces is required only when this function is called while + * the streaming base backup requested by pg_basebackup is running. + * NULL should be specified otherwise. + * * tblspcmapfile is required mainly for tar format in windows as native windows * utilities are not able to create symlinks while extracting files from tar. * However for consistency, the same is used for all platforms. @@ -10470,6 +10475,14 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p, 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 */ tblspcdir = AllocateDir("pg_tblspc"); while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL) -- cgit v1.2.3