Skip to content

Commit e1880c5

Browse files
committed
minor bugfix: close ssh connection when it is not needed anymore
1 parent b231d84 commit e1880c5

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/backup.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ do_backup_instance(PGconn *backup_conn)
344344
dir_list_file(backup_files_list, parray_get(external_dirs, i),
345345
false, true, false, i+1, FIO_DB_HOST);
346346

347+
/* close ssh session in main thread */
348+
fio_disconnect();
349+
347350
/* Sanity check for backup_files_list, thank you, Windows:
348351
* https://github.com/postgrespro/pg_probackup/issues/48
349352
*/
@@ -512,6 +515,9 @@ do_backup_instance(PGconn *backup_conn)
512515
parray_free(prev_backup_filelist);
513516
}
514517

518+
/* Notify end of backup */
519+
pg_stop_backup(&current, pg_startbackup_conn);
520+
515521
/* In case of backup from replica >= 9.6 we must fix minRecPoint,
516522
* First we must find pg_control in backup_files_list.
517523
*/
@@ -532,16 +538,16 @@ do_backup_instance(PGconn *backup_conn)
532538
break;
533539
}
534540
}
535-
}
536-
537-
/* ssh connection to longer needed */
538-
fio_disconnect();
539541

540-
/* Notify end of backup */
541-
pg_stop_backup(&current, pg_startbackup_conn);
542+
if (!pg_control)
543+
elog(ERROR, "Failed to find file \"%s\" in backup filelist.",
544+
pg_control_path);
542545

543-
if (current.from_replica && !exclusive_backup)
544546
set_min_recovery_point(pg_control, database_path, current.stop_lsn);
547+
}
548+
549+
/* close ssh session in main thread */
550+
fio_disconnect();
545551

546552
/* Add archived xlog files into the list of files of this backup */
547553
if (stream_wal)
@@ -683,9 +689,6 @@ do_backup(time_t start_time, bool no_validate)
683689
*/
684690
check_system_identifiers(backup_conn, instance_config.pgdata);
685691

686-
/* ssh connection to longer needed */
687-
fio_disconnect();
688-
689692
/* below perform checks specific for backup command */
690693
#if PG_VERSION_NUM >= 110000
691694
if (!RetrieveWalSegSize(backup_conn))

0 commit comments

Comments
 (0)