Skip to content

Commit

Permalink
[enhance]change SpinLock to mutex for _tablets_channels_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
cjj2010 committed Sep 27, 2024
1 parent 9c7714a commit abc864d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions be/src/runtime/load_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Status LoadChannel::open(const PTabletWriterOpenRequest& params) {
int64_t index_id = params.index_id();
std::shared_ptr<BaseTabletsChannel> channel;
{
std::lock_guard<std::mutex> l(_lock);
(std::lock_guard<std::mutex>(_lock));
auto it = _tablets_channels.find(index_id);
if (it != _tablets_channels.end()) {
channel = it->second;
Expand All @@ -142,7 +142,7 @@ Status LoadChannel::open(const PTabletWriterOpenRequest& params) {
_is_high_priority, _self_profile);
}
{
std::lock_guard<SpinLock> l(_tablets_channels_lock);
std::lock_guard<std::mutex> l(_tablets_channels_lock);
_tablets_channels.insert({index_id, channel});
}
}
Expand Down Expand Up @@ -244,7 +244,7 @@ Status LoadChannel::_handle_eos(BaseTabletsChannel* channel,
if (finished) {
std::lock_guard<std::mutex> l(_lock);
{
std::lock_guard<SpinLock> l(_tablets_channels_lock);
std::lock_guard<std::mutex> l(_tablets_channels_lock);
_tablets_channels_rows.insert(std::make_pair(
index_id,
std::make_pair(channel->total_received_rows(), channel->num_rows_filtered())));
Expand All @@ -270,7 +270,7 @@ void LoadChannel::_report_profile(PTabletWriterAddBlockResult* response) {
_self_profile->set_timestamp(_last_updated_time);

{
std::lock_guard<SpinLock> l(_tablets_channels_lock);
std::lock_guard<std::mutex> l(_tablets_channels_lock);
for (auto& it : _tablets_channels) {
it.second->refresh_profile();
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/runtime/load_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class LoadChannel {
std::unordered_map<int64_t, std::shared_ptr<BaseTabletsChannel>> _tablets_channels;
// index id -> (received rows, filtered rows)
std::unordered_map<int64_t, std::pair<size_t, size_t>> _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<int64_t> _finished_channel_ids;
// set to true if at least one tablets channel has been opened
Expand Down

0 comments on commit abc864d

Please sign in to comment.