From 1dafd26a2d0822d8943d96f1b9fe1c6650bb7452 Mon Sep 17 00:00:00 2001 From: cjj2010 <2449402815@qq.com> Date: Fri, 27 Sep 2024 11:16:59 +0800 Subject: [PATCH 1/2] [enhance]change SpinLock to mutex for _tablets_channels_lock --- be/src/runtime/load_channel.cpp | 8 ++++---- be/src/runtime/load_channel.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/be/src/runtime/load_channel.cpp b/be/src/runtime/load_channel.cpp index 1ac7753b19784b..dd0d1110e7ea24 100644 --- a/be/src/runtime/load_channel.cpp +++ b/be/src/runtime/load_channel.cpp @@ -115,7 +115,7 @@ Status LoadChannel::open(const PTabletWriterOpenRequest& params) { int64_t index_id = params.index_id(); std::shared_ptr channel; { - std::lock_guard l(_lock); + (std::lock_guard(_lock)); auto it = _tablets_channels.find(index_id); if (it != _tablets_channels.end()) { channel = it->second; @@ -135,7 +135,7 @@ Status LoadChannel::open(const PTabletWriterOpenRequest& params) { _is_high_priority, _self_profile); } { - std::lock_guard l(_tablets_channels_lock); + std::lock_guard l(_tablets_channels_lock); _tablets_channels.insert({index_id, channel}); } } @@ -237,7 +237,7 @@ Status LoadChannel::_handle_eos(BaseTabletsChannel* channel, if (finished) { std::lock_guard l(_lock); { - std::lock_guard l(_tablets_channels_lock); + std::lock_guard l(_tablets_channels_lock); _tablets_channels_rows.insert(std::make_pair( index_id, std::make_pair(channel->total_received_rows(), channel->num_rows_filtered()))); @@ -263,7 +263,7 @@ void LoadChannel::_report_profile(PTabletWriterAddBlockResult* response) { _self_profile->set_timestamp(_last_updated_time); { - std::lock_guard l(_tablets_channels_lock); + std::lock_guard l(_tablets_channels_lock); for (auto& it : _tablets_channels) { it.second->refresh_profile(); } diff --git a/be/src/runtime/load_channel.h b/be/src/runtime/load_channel.h index 6c150ed74d9126..36a8f363ba9bac 100644 --- a/be/src/runtime/load_channel.h +++ b/be/src/runtime/load_channel.h @@ -104,7 +104,7 @@ class LoadChannel { std::unordered_map> _tablets_channels; // index id -> (received rows, filtered rows) std::unordered_map> _tablets_channels_rows; - SpinLock _tablets_channels_lock; + std::mutex _tablets_channels_lock; // This is to save finished channels id, to handle the retry request. std::unordered_set _finished_channel_ids; // set to true if at least one tablets channel has been opened From 2d4ba01e8f1bc50eab0fb3a53dca06c7c4302cf3 Mon Sep 17 00:00:00 2001 From: cjj2010 <2449402815@qq.com> Date: Fri, 27 Sep 2024 11:26:55 +0800 Subject: [PATCH 2/2] [enhance]change SpinLock to mutex for _tablets_channels_lock --- be/src/runtime/load_channel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/src/runtime/load_channel.cpp b/be/src/runtime/load_channel.cpp index dd0d1110e7ea24..9369c0c833c53c 100644 --- a/be/src/runtime/load_channel.cpp +++ b/be/src/runtime/load_channel.cpp @@ -115,7 +115,7 @@ Status LoadChannel::open(const PTabletWriterOpenRequest& params) { int64_t index_id = params.index_id(); std::shared_ptr channel; { - (std::lock_guard(_lock)); + std::lock_guard l(_lock); auto it = _tablets_channels.find(index_id); if (it != _tablets_channels.end()) { channel = it->second;