Skip to content

Commit 433cacf

Browse files
committed
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.
1 parent b8cf89c commit 433cacf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/replication/basebackup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
109109

110110
startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &starttli,
111111
&labelfile);
112-
SendXlogRecPtrResult(startptr, starttli);
113112

114113
PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
115114
{
@@ -118,6 +117,8 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
118117
struct dirent *de;
119118
tablespaceinfo *ti;
120119

120+
SendXlogRecPtrResult(startptr, starttli);
121+
121122
/* Collect information about all tablespaces */
122123
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
123124
{

0 commit comments

Comments
 (0)