Skip to content

Commit 82af8f3

Browse files
committed
[Issue #346] detect failure of streaming thread
1 parent fd73b9c commit 82af8f3

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

src/backup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ wait_wal_lsn(XLogRecPtr target_lsn, bool is_start_lsn, TimeLineID tli,
14051405
}
14061406

14071407
sleep(1);
1408-
if (interrupted)
1408+
if (interrupted || thread_interrupted)
14091409
elog(ERROR, "Interrupted during waiting for WAL %s", in_stream_dir ? "streaming" : "archiving");
14101410
try_count++;
14111411

src/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ get_checksum_map(const char *fullpath, uint32 checksum_version,
18511851
if (feof(in))
18521852
break;
18531853

1854-
if (interrupted)
1854+
if (interrupted || thread_interrupted)
18551855
elog(ERROR, "Interrupted during page reading");
18561856
}
18571857

@@ -1914,7 +1914,7 @@ get_lsn_map(const char *fullpath, uint32 checksum_version,
19141914
if (feof(in))
19151915
break;
19161916

1917-
if (interrupted)
1917+
if (interrupted || thread_interrupted)
19181918
elog(ERROR, "Interrupted during page reading");
19191919
}
19201920

src/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,8 @@ dir_check_file(pgFile *file, bool backup_logs)
781781
* List files in parent->path directory. If "exclude" is true do not add into
782782
* "files" files from pgdata_exclude_files and directories from
783783
* pgdata_exclude_dir.
784+
*
785+
* TODO: should we check for interrupt here ?
784786
*/
785787
static void
786788
dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,

src/stream.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ StreamLog(void *arg)
233233
ctl.mark_done = false;
234234

235235
if(ReceiveXlogStream(stream_arg->conn, &ctl) == false)
236+
{
237+
interrupted = true;
236238
elog(ERROR, "Problem in receivexlog");
239+
}
237240

238241
#if PG_VERSION_NUM >= 100000
239242
if (!ctl.walmethod->finish())
@@ -245,7 +248,10 @@ StreamLog(void *arg)
245248
if(ReceiveXlogStream(stream_arg->conn, stream_arg->startpos, stream_arg->starttli,
246249
NULL, (char *) stream_arg->basedir, stop_streaming,
247250
standby_message_timeout, NULL, false, false) == false)
251+
{
252+
interrupted = true;
248253
elog(ERROR, "Problem in receivexlog");
254+
}
249255
#endif
250256

251257
/* be paranoid and sort xlog_files_list,

src/utils/logger.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ exit_if_necessary(int elevel)
169169
{
170170
/* Interrupt other possible routines */
171171
thread_interrupted = true;
172-
interrupted = true;
173172
#ifdef WIN32
174173
ExitThread(elevel);
175174
#else

0 commit comments

Comments
 (0)