aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2014-05-28 13:03:21 +0200
committerMagnus Hagander <magnus@hagander.net>2014-05-28 13:04:08 +0200
commit0282dc2551e32f486b173c3104c3ecdf6d345e67 (patch)
tree254c5238fec7012d2b0af779448eb8279307cd93 /src
parent3ae8e8bf552f622600b1a356550882e886753119 (diff)
downloadpostgresql-0282dc2551e32f486b173c3104c3ecdf6d345e67.tar.gz
postgresql-0282dc2551e32f486b173c3104c3ecdf6d345e67.zip
Ensure cleanup in case of early errors in streaming base backups
Move the code that sends the initial status information as well as the calculation of paths inside the ENSURE_ERROR_CLEANUP block. If this code failed, we would "leak" a counter of number of concurrent backups, thereby making the system always believe it was in backup mode. This could happen if the sending failed (which it probably never did given that the small amount of data to send would never cause a flush). It is very low risk, but all operations after do_pg_start_backup should be protected.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/basebackup.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index a387f42a606..ddda0c91416 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -101,7 +101,6 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
datadirpathlen = strlen(DataDir);
startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &labelfile);
- SendXlogRecPtrResult(startptr);
PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
{
@@ -110,6 +109,8 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
struct dirent *de;
tablespaceinfo *ti;
+ SendXlogRecPtrResult(startptr);
+
/* Collect information about all tablespaces */
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
{