]> granicus.if.org Git - postgresql/commitdiff
Ensure cleanup in case of early errors in streaming base backups
authorMagnus Hagander <magnus@hagander.net>
Wed, 28 May 2014 11:03:21 +0000 (13:03 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 28 May 2014 11:04:08 +0000 (13:04 +0200)
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.

src/backend/replication/basebackup.c

index a387f42a606c7031e1fe355db9c1f9c384abc221..ddda0c91416f92d0b9047aa42540cba042c92267 100644 (file)
@@ -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)
                {