Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita742f2b

Browse files
committed
Stop backup if we can't connect by stream protocol with --stream option.
1 parentc8a6900 commita742f2b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎backup.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ parray*backup_files_list;
4242
staticvolatileuint32total_copy_files_increment;
4343
staticuint32total_files_num;
4444
staticPGconn*start_stop_connect=NULL;
45+
staticpthread_mutex_tcheck_stream_mut=PTHREAD_MUTEX_INITIALIZER;
4546

4647
typedefstruct
4748
{
@@ -170,7 +171,12 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
170171
pgBackupGetPath(&current,path,lengthof(path),DATABASE_DIR);
171172
join_path_components(dst_backup_path,path,"pg_xlog");
172173
dir_create_dir(dst_backup_path,DIR_PERMISSION);
174+
pthread_mutex_lock(&check_stream_mut);
173175
pthread_create(&stream_thread,NULL, (void*(*)(void*))StreamLog,dst_backup_path);
176+
pthread_mutex_lock(&check_stream_mut);
177+
if (conn==NULL)
178+
elog(ERROR,"I can't continue work because stream connect has failed.");
179+
pthread_mutex_unlock(&check_stream_mut);
174180
}
175181

176182
if(!from_replica)
@@ -1457,8 +1463,11 @@ StreamLog(void *arg)
14571463
if (conn==NULL)
14581464
conn=GetConnection();
14591465
if (!conn)
1466+
{
1467+
pthread_mutex_unlock(&check_stream_mut);
14601468
/* Error message already written in GetConnection() */
14611469
return;
1470+
}
14621471

14631472
if (!CheckServerVersionForStreaming(conn))
14641473
{
@@ -1478,6 +1487,8 @@ StreamLog(void *arg)
14781487
if (!RunIdentifySystem(conn,NULL,&starttli,&startpos,NULL))
14791488
disconnect_and_exit(1);
14801489

1490+
/* Ok we have normal stream connect and main process can work again */
1491+
pthread_mutex_unlock(&check_stream_mut);
14811492
/*
14821493
* We must use startpos as start_lsn from start_backup
14831494
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp