[fix](bthread) fix bthread hang (#16594)

This commit is contained in:
YueW
2023-02-14 00:08:57 +08:00
committed by GitHub
parent de725d5d44
commit ed3420000e
2 changed files with 4 additions and 3 deletions

View File

@ -159,7 +159,7 @@ private:
std::string _group;
int _timeout_second;
bool _cancelled = false;
std::atomic<bool> _cancelled {false};
// This context is shared by all fragments of this host in a query
std::shared_ptr<QueryFragmentsCtx> _fragments_ctx;

View File

@ -694,8 +694,9 @@ Status VNodeChannel::close_wait(RuntimeState* state) {
}
// waiting for finished, it may take a long time, so we couldn't set a timeout
while (!_add_batches_finished && !_cancelled) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
while (!_add_batches_finished && !_cancelled && !state->is_cancelled()) {
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
bthread_usleep(1000);
}
_close_time_ms = UnixMillis() - _close_time_ms;