From b88b929a707145964b707257049f8dbfd58f0da5 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 1 Apr 2017 17:20:05 +0200 Subject: [PATCH] Back-patch checkpoint clarification docs and pg_basebackup updates This backpatches 51e26c9 and 7220c7b, including both documentation updates clarifying the checkpoints at the beginning of base backups and the messages in verbose and progress mdoe of pg_basebackup. Author: Michael Banck Discussion: https://postgr.es/m/21444.1488142764%40sss.pgh.pa.us --- doc/src/sgml/backup.sgml | 3 ++- doc/src/sgml/ref/pg_basebackup.sgml | 10 +++++++++- src/bin/pg_basebackup/pg_basebackup.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml index 8c0bb1f6a20..03c0dbf1cd0 100644 --- a/doc/src/sgml/backup.sgml +++ b/doc/src/sgml/backup.sgml @@ -862,7 +862,8 @@ SELECT pg_start_backup('label', false, false); ). This is usually what you want, because it minimizes the impact on query processing. If you want to start the backup as soon as - possible, change the second parameter to true. + possible, change the second parameter to true, which will + issue an immediate checkpoint using as much I/O as available. diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index 95c801627b3..134b2982368 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -382,7 +382,7 @@ PostgreSQL documentation - Sets checkpoint mode to fast or spread (default) (see ). + Sets checkpoint mode to fast (immediate) or spread (default) (see ). @@ -589,6 +589,14 @@ PostgreSQL documentation Notes + + At the beginning of the backup, a checkpoint needs to be written on the + server the backup is taken from. Especially if the option + --checkpoint=fast is not used, this can take some time + during which pg_basebackup will be appear + to be idle. + + The backup will include all files in the data directory and tablespaces, including the configuration files and any additional files placed in the diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index a5bc3225337..613f2e159c3 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1661,6 +1661,14 @@ BaseBackup(void) if (maxrate > 0) maxrate_clause = psprintf("MAX_RATE %u", maxrate); + if (verbose) + fprintf(stderr, + _("%s: initiating base backup, waiting for checkpoint to complete\n"), + progname); + + if (showprogress && !verbose) + fprintf(stderr, "waiting for checkpoint\r"); + basebkp = psprintf("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s", escaped_label, @@ -1698,6 +1706,9 @@ BaseBackup(void) strlcpy(xlogstart, PQgetvalue(res, 0, 0), sizeof(xlogstart)); + if (verbose) + fprintf(stderr, _("%s: checkpoint completed\n"), progname); + /* * 9.3 and later sends the TLI of the starting point. With older servers, * assume it's the same as the latest timeline reported by -- 2.39.5