8000 Ensure cleanup in case of early errors in streaming base backups · larkly/postgres-docker@0282dc2 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 0282dc2

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 3ae8e8b commit 0282dc2

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
@@ -101,7 +101,6 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
101101
datadirpathlen = strlen(DataDir);
102102

103103
startptr = do_pg_start_backup(opt->label, opt->fastcheckpoint, &labelfile);
104-
SendXlogRecPtrResult(startptr);
105104

106105
PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
107106
{
@@ -110,6 +109,8 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
110109
struct dirent *de;
111110
tablespaceinfo *ti;
112111

112+
SendXlogRecPtrResult(startptr);
113+
113114
/* Collect information about all tablespaces */
114115
while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
115116
{

0 commit comments

Comments
 (0)
0