-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Split the admin command out of the main thread #2727
Changes from 1 commit
3076d39
be96fed
e7fd91b
b342a21
63ccac0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,14 @@ int PikaConf::Load() { | |
slow_cmd_thread_pool_size_ = 100; | ||
} | ||
|
||
GetConfInt("admin-thread-pool-size", &admin_thread_pool_size_); | ||
if (admin_thread_pool_size_ <= 0) { | ||
admin_thread_pool_size_ = 2; | ||
} | ||
if (admin_thread_pool_size_ > 4) { | ||
admin_thread_pool_size_ = 4; | ||
} | ||
Comment on lines
+169
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate the bounds for The validation for Update related documentation and example configurations. Please ensure that the addition of the |
||
|
||
std::string slow_cmd_list; | ||
GetConfStr("slow-cmd-list", &slow_cmd_list); | ||
SetSlowCmd(slow_cmd_list); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,7 +171,8 @@ void BlockingBaseCmd::TryToServeBLrPopWithThisKey(const std::string& key, std::s | |
|
||
auto* args = new UnblockTaskArgs(key, std::move(db), dispatchThread); | ||
bool is_slow_cmd = g_pika_conf->is_slow_cmd("LPOP") || g_pika_conf->is_slow_cmd("RPOP"); | ||
g_pika_server->ScheduleClientPool(&ServeAndUnblockConns, args, is_slow_cmd); | ||
bool is_monitor_cmd = false; | ||
g_pika_server->ScheduleClientPool(&ServeAndUnblockConns, args, is_slow_cmd, is_monitor_cmd); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The variable
Analysis chainVerify the handling of The variable Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify if there are conditions or configurations that should set `is_monitor_cmd` to true.
# Test: Search for conditions that affect `is_monitor_cmd` in the codebase.
rg --type cpp $'is_monitor_cmd = .*;'
Length of output: 306 Script: #!/bin/bash
# Extract and analyze the relevant code segments from src/pika_client_conn.cc where is_monitor_cmd is set.
rg --type cpp --context 5 $'is_monitor_cmd =' src/pika_client_conn.cc
Length of output: 821 |
||
} | ||
|
||
void BlockingBaseCmd::ServeAndUnblockConns(void* args) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,7 @@ PikaServer::~PikaServer() { | |
// so we need to delete dispatch before worker. | ||
pika_client_processor_->Stop(); | ||
pika_slow_cmd_thread_pool_->stop_thread_pool(); | ||
pika_admin_cmd_thread_pool_->stop_thread_pool(); | ||
{ | ||
std::lock_guard l(slave_mutex_); | ||
auto iter = slaves_.begin(); | ||
|
@@ -172,6 +173,12 @@ void PikaServer::Start() { | |
LOG(FATAL) << "Start PikaLowLevelThreadPool Error: " << ret | ||
<< (ret == net::kCreateThreadError ? ": create thread error " : ": other error"); | ||
} | ||
ret = pika_admin_cmd_thread_pool_->start_thread_pool(); | ||
if (ret != net::kSuccess) { | ||
dbs_.clear(); | ||
LOG(FATAL) << "Start PikaAdminThreadPool Error: " << ret | ||
<< (ret == net::kCreateThreadError ? ": create thread error " : ": other error"); | ||
} | ||
ret = pika_dispatch_thread_->StartThread(); | ||
if (ret != net::kSuccess) { | ||
dbs_.clear(); | ||
|
@@ -706,11 +713,15 @@ void PikaServer::SetFirstMetaSync(bool v) { | |
first_meta_sync_ = v; | ||
} | ||
|
||
void PikaServer::ScheduleClientPool(net::TaskFunc func, void* arg, bool is_slow_cmd) { | ||
void PikaServer::ScheduleClientPool(net::TaskFunc func, void* arg, bool is_slow_cmd, bool is_monitor_cmd) { | ||
if (is_slow_cmd) { | ||
pika_slow_cmd_thread_pool_->Schedule(func, arg); | ||
return; | ||
} | ||
if (is_monitor_cmd) { | ||
pika_admin_cmd_thread_pool_->Schedule(func, arg); | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes to |
||
pika_client_processor_->SchedulePool(func, arg); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Initialization and Cleanup of Admin Command Thread Pool
The
pika_admin_cmd_thread_pool_
is initialized and used insrc/pika_server.cc
. However, there is no evidence of its cleanup in the destructor. Ensure that the thread pool is properly stopped and cleaned up to avoid resource leaks.src/pika_server.cc
: Initialization and usage ofpika_admin_cmd_thread_pool_
found, but no cleanup in the destructor.Analysis chain
Initialization and Cleanup of Admin Command Thread Pool
The
pika_admin_cmd_thread_pool_
has been added to handle admin commands. Ensure that this thread pool is appropriately initialized in the constructor and properly cleaned up in the destructor to avoid resource leaks.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 234
Script:
Length of output: 482