Skip to content

Commit 556bc43

Browse files
authored
Revert "fix: fix exit core (#3050)" (#3052)
This reverts commit 5c2ecdb.
1 parent 5c2ecdb commit 556bc43

5 files changed

Lines changed: 12 additions & 18 deletions

File tree

conf/pika.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ admin-thread-pool-size : 2
4545
slow-cmd-list :
4646

4747
# List of commands considered as administrative. These commands will be handled by the admin thread pool. Modify this list as needed.
48-
# Default commands: info, ping, monitor, auth
48+
# Default commands: info, ping, monitor
4949
# This parameter is only supported by the CONFIG GET command and not by CONFIG SET.
50-
admin-cmd-list : info, ping, monitor, auth
50+
admin-cmd-list : info, ping, monitor
5151

5252
# The number of threads to write DB in slaveNode when replicating.
5353
# It's preferable to set slave's sync-thread-num value close to master's thread-pool-size.

include/pika_cmd_table_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class PikaCmdTableManager {
7373
*/
7474
std::unordered_map<std::string, CommandStatistics> cmdstat_map_;
7575
std::unordered_map<std::string, CommandStatistics> slow_command_count_;
76+
std::thread reset_thread_;
7677
std::mutex command_mutex_;
7778
std::shared_mutex histograms_mutex_;
7879
std::shared_mutex slow_command_mutex_;

include/pika_server.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ class PikaServer : public pstd::noncopyable {
259259
void ResetStat();
260260
void incr_accumulative_connections();
261261
void ResetLastSecQuerynum();
262-
void ResetCommandCount();
263262
void UpdateQueryNumAndExecCountDB(const std::string& db_name, const std::string& command, bool is_write);
264263
std::unordered_map<std::string, uint64_t> ServerExecCountDB();
265264
std::unordered_map<std::string, QpsStatistic> ServerAllDBStat();

src/pika_cmd_table_manager.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515
extern std::unique_ptr<PikaConf> g_pika_conf;
1616

1717
void PikaCmdTableManager::ResetCommandCount() {
18-
std::lock_guard<std::mutex> lock(command_mutex_);
19-
slow_command_count_.clear();
20-
InitHistograms();
18+
while (true) {
19+
std::this_thread::sleep_for(std::chrono::minutes(1));
20+
{
21+
std::lock_guard<std::mutex> lock(command_mutex_);
22+
slow_command_count_.clear();
23+
InitHistograms();
24+
}
25+
}
2126
}
2227

2328
void PikaCmdTableManager::InitHistograms() {
@@ -33,6 +38,7 @@ PikaCmdTableManager::PikaCmdTableManager() {
3338
cmds_ = std::make_unique<CmdTable>();
3439
cmds_->reserve(300);
3540
InitHistograms();
41+
reset_thread_ = std::thread(&PikaCmdTableManager::ResetCommandCount, this);
3642
}
3743

3844
void PikaCmdTableManager::InitCmdTable(void) {

src/pika_server.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,16 +1033,6 @@ void PikaServer::ResetLastSecQuerynum() {
10331033
statistic_.ResetDBLastSecQuerynum();
10341034
}
10351035

1036-
void PikaServer::ResetCommandCount() {
1037-
thread_local uint64_t last_reset_time = 0;
1038-
auto current_time = pstd::NowMicros();
1039-
if (current_time - last_reset_time < 60 * 1000 * 1000) {
1040-
return;
1041-
}
1042-
last_reset_time = current_time;
1043-
g_pika_cmd_table_manager->ResetCommandCount();
1044-
}
1045-
10461036
void PikaServer::UpdateQueryNumAndExecCountDB(const std::string& db_name, const std::string& command, bool is_write) {
10471037
std::string cmd(command);
10481038
statistic_.server_stat.qps.querynum++;
@@ -1149,8 +1139,6 @@ void PikaServer::DoTimingTask() {
11491139
ResetLastSecQuerynum();
11501140
// Auto update network instantaneous metric
11511141
AutoUpdateNetworkMetric();
1152-
// Reset command statistics
1153-
ResetCommandCount();
11541142
ProcessCronTask();
11551143
UpdateCacheInfo();
11561144
// Print the queue status periodically

0 commit comments

Comments
 (0)