Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/pika_cmd_table_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class PikaCmdTableManager {
*/
std::unordered_map<std::string, CommandStatistics> cmdstat_map_;
std::unordered_map<std::string, CommandStatistics> slow_command_count_;
std::mutex command_mutex_;
std::shared_mutex histograms_mutex_;
std::shared_mutex slow_command_mutex_;
std::shared_ptr<prometheus::Registry> prometheus_registry_;
Expand Down
13 changes: 10 additions & 3 deletions src/pika_cmd_table_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
extern std::unique_ptr<PikaConf> g_pika_conf;

void PikaCmdTableManager::ResetCommandCount() {
std::lock_guard<std::mutex> lock(command_mutex_);
slow_command_count_.clear();
InitHistograms();
{
std::unique_lock<std::shared_mutex> write_lock(slow_command_mutex_);
slow_command_count_.clear();
}

{
std::unique_lock<std::shared_mutex> write_lock(histograms_mutex_);
InitHistograms();
}
}

void PikaCmdTableManager::InitHistograms() {
Expand Down Expand Up @@ -97,6 +103,7 @@ prometheus::Histogram& PikaCmdTableManager::GetHistogram(const std::string& opt)
}

prometheus::Family<prometheus::Histogram>* PikaCmdTableManager::GetHistograms() {
std::shared_lock<std::shared_mutex> read_lock(histograms_mutex_);
return histogram_family_;
}

Expand Down
Loading