Skip to content

Commit 62b64ea

Browse files
authored
Merge pull request #2018 from joto/fix-postproc-exception
Fix a crash when an exception is thrown in postprocessing
2 parents 1f708bd + 6c3f9eb commit 62b64ea

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/output-flex.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,22 @@ void output_flex_t::stop()
10761076

10771077
void output_flex_t::wait()
10781078
{
1079+
std::exception_ptr eptr;
1080+
flex_table_t const *table_with_error = nullptr;
1081+
10791082
for (auto &table : m_table_connections) {
1080-
table.task_wait();
1083+
try {
1084+
table.task_wait();
1085+
} catch (...) {
1086+
eptr = std::current_exception();
1087+
table_with_error = &table.table();
1088+
}
1089+
}
1090+
1091+
if (eptr) {
1092+
log_error("Error while doing postprocessing on table '{}':",
1093+
table_with_error->name());
1094+
std::rethrow_exception(eptr);
10811095
}
10821096
}
10831097

src/output-pgsql.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,16 @@ void output_pgsql_t::stop()
159159

160160
void output_pgsql_t::wait()
161161
{
162+
std::exception_ptr eptr;
162163
for (auto &t : m_tables) {
163-
t->task_wait();
164+
try {
165+
t->task_wait();
166+
} catch (...) {
167+
eptr = std::current_exception();
168+
}
169+
}
170+
if (eptr) {
171+
std::rethrow_exception(eptr);
164172
}
165173
}
166174

0 commit comments

Comments
 (0)