mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-04-14 12:08:44 +02:00
Stop backup if we can't connect by stream protocol with --stream option.
This commit is contained in:
parent
c8a690018e
commit
a742f2b04e
11
backup.c
11
backup.c
@ -42,6 +42,7 @@ parray *backup_files_list;
|
|||||||
static volatile uint32 total_copy_files_increment;
|
static volatile uint32 total_copy_files_increment;
|
||||||
static uint32 total_files_num;
|
static uint32 total_files_num;
|
||||||
static PGconn *start_stop_connect = NULL;
|
static PGconn *start_stop_connect = NULL;
|
||||||
|
static pthread_mutex_t check_stream_mut = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -170,7 +171,12 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
|
|||||||
pgBackupGetPath(¤t, path, lengthof(path), DATABASE_DIR);
|
pgBackupGetPath(¤t, path, lengthof(path), DATABASE_DIR);
|
||||||
join_path_components(dst_backup_path, path, "pg_xlog");
|
join_path_components(dst_backup_path, path, "pg_xlog");
|
||||||
dir_create_dir(dst_backup_path, DIR_PERMISSION);
|
dir_create_dir(dst_backup_path, DIR_PERMISSION);
|
||||||
|
pthread_mutex_lock(&check_stream_mut);
|
||||||
pthread_create(&stream_thread, NULL, (void *(*)(void *)) StreamLog, dst_backup_path);
|
pthread_create(&stream_thread, NULL, (void *(*)(void *)) StreamLog, dst_backup_path);
|
||||||
|
pthread_mutex_lock(&check_stream_mut);
|
||||||
|
if (conn == NULL)
|
||||||
|
elog(ERROR, "I can't continue work because stream connect has failed.");
|
||||||
|
pthread_mutex_unlock(&check_stream_mut);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!from_replica)
|
if(!from_replica)
|
||||||
@ -1457,8 +1463,11 @@ StreamLog(void *arg)
|
|||||||
if (conn == NULL)
|
if (conn == NULL)
|
||||||
conn = GetConnection();
|
conn = GetConnection();
|
||||||
if (!conn)
|
if (!conn)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&check_stream_mut);
|
||||||
/* Error message already written in GetConnection() */
|
/* Error message already written in GetConnection() */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!CheckServerVersionForStreaming(conn))
|
if (!CheckServerVersionForStreaming(conn))
|
||||||
{
|
{
|
||||||
@ -1478,6 +1487,8 @@ StreamLog(void *arg)
|
|||||||
if (!RunIdentifySystem(conn, NULL, &starttli, &startpos, NULL))
|
if (!RunIdentifySystem(conn, NULL, &starttli, &startpos, NULL))
|
||||||
disconnect_and_exit(1);
|
disconnect_and_exit(1);
|
||||||
|
|
||||||
|
/* Ok we have normal stream connect and main process can work again */
|
||||||
|
pthread_mutex_unlock(&check_stream_mut);
|
||||||
/*
|
/*
|
||||||
* We must use startpos as start_lsn from start_backup
|
* We must use startpos as start_lsn from start_backup
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user