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

Skip to content

Commit dbcde0f

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 9a21ac0 commit dbcde0f

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