[fix](quit) be can not quit cleanly due to deadlock (#17971)
This commit is contained in:
@ -121,8 +121,8 @@ Status DataDir::init() {
|
||||
}
|
||||
|
||||
void DataDir::stop_bg_worker() {
|
||||
std::unique_lock<std::mutex> lck(_check_path_mutex);
|
||||
_stop_bg_worker = true;
|
||||
std::unique_lock<std::mutex> lck(_check_path_mutex);
|
||||
_check_path_cv.notify_one();
|
||||
}
|
||||
|
||||
@ -669,6 +669,10 @@ void DataDir::perform_path_scan() {
|
||||
continue;
|
||||
}
|
||||
for (const auto& tablet_id : tablet_ids) {
|
||||
if (_stop_bg_worker) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto tablet_id_path = fmt::format("{}/{}", shard_path, tablet_id);
|
||||
std::set<std::string> schema_hashes;
|
||||
ret = FileUtils::list_dirs_files(tablet_id_path, &schema_hashes, nullptr,
|
||||
@ -681,6 +685,9 @@ void DataDir::perform_path_scan() {
|
||||
|
||||
for (const auto& schema_hash : schema_hashes) {
|
||||
int32_t interval_ms = config::path_scan_step_interval_ms;
|
||||
if (_stop_bg_worker) {
|
||||
break;
|
||||
}
|
||||
if (interval_ms > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(interval_ms));
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ private:
|
||||
bool _check_pending_ids(const std::string& id);
|
||||
|
||||
private:
|
||||
bool _stop_bg_worker = false;
|
||||
std::atomic<bool> _stop_bg_worker = false;
|
||||
|
||||
std::string _path;
|
||||
size_t _path_hash;
|
||||
|
||||
Reference in New Issue
Block a user