Skip to content

Commit

Permalink
Merge branch 'OpenAtomFoundation:unstable' into admin_thread
Browse files Browse the repository at this point in the history
  • Loading branch information
chejinge authored and brother-jin committed Jun 26, 2024
2 parents b342a21 + 8730946 commit 63ccac0
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
6 changes: 5 additions & 1 deletion conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ slow-cmd-pool : no
# are dedicated to handling slow user requests.
slow-cmd-thread-pool-size : 1


# Size of the low level thread pool, The threads within this pool
# are dedicated to handling slow user requests.
admin-thread-pool-size : 2

# Slow cmd list e.g. hgetall, mset
slow-cmd-list :

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

# The number of threads to write DB in slaveNode when replicating.
# It's preferable to set slave's sync-thread-num value close to master's thread-pool-size.
sync-thread-num : 6
Expand Down
1 change: 0 additions & 1 deletion include/pika_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ enum CmdFlags {
kCmdFlagsStream = (1 << 20),
kCmdFlagsFast = (1 << 21),
kCmdFlagsSlow = (1 << 22),
kCmdFlagsMonitor = (1 << 23),
};

void inline RedisAppendContent(std::string& str, const std::string& value);
Expand Down
3 changes: 1 addition & 2 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ class PikaConf : public pstd::BaseConf {
}

bool is_admin_cmd(const std::string& cmd) {
std::shared_lock l(rwlock_);
return admin_cmd_set_.find(cmd) != admin_cmd_set_.end();
}

Expand Down Expand Up @@ -839,7 +838,7 @@ class PikaConf : public pstd::BaseConf {
std::string lower_value = value;
pstd::StringToLower(lower_value);
TryPushDiffCommands("admin-cmd-list", lower_value);
pstd::StringSplit2Set(lower_value, ',', slow_cmd_set_);
pstd::StringSplit2Set(lower_value, ',', admin_cmd_set_);
}

void SetCacheType(const std::string &value);
Expand Down
2 changes: 1 addition & 1 deletion include/pika_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class PikaServer : public pstd::noncopyable {
/*
* PikaClientProcessor Process Task
*/
void ScheduleClientPool(net::TaskFunc func, void* arg, bool is_slow_cmd, bool is_monitor_cmd);
void ScheduleClientPool(net::TaskFunc func, void* arg, bool is_slow_cmd, bool is_admin_cmd);

// for info debug
size_t ClientProcessorThreadPoolCurQueueSize();
Expand Down
4 changes: 0 additions & 4 deletions src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,6 @@ void ConfigCmd::ConfigSet(std::shared_ptr<DB> db) {
"slave-priority",
"sync-window-size",
"slow-cmd-list",
"admin-cmd-list",
// Options for storage engine
// MutableDBOptions
"max-cache-files",
Expand Down Expand Up @@ -2529,9 +2528,6 @@ void ConfigCmd::ConfigSet(std::shared_ptr<DB> db) {
} else if (set_item == "slow-cmd-list") {
g_pika_conf->SetSlowCmd(value);
res_.AppendStringRaw("+OK\r\n");
} else if (set_item == "admin-cmd-list") {
g_pika_conf->SetAdminCmd(value);
res_.AppendStringRaw("+OK\r\n");
} else if (set_item == "max-cache-files") {
if (pstd::string2int(value.data(), value.size(), &ival) == 0) {
res_.AppendStringRaw("-ERR Invalid argument \'" + value + "\' for CONFIG SET 'max-cache-files'\r\n");
Expand Down
4 changes: 2 additions & 2 deletions src/pika_client_conn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ void PikaClientConn::ProcessRedisCmds(const std::vector<net::RedisCmdArgsType>&
std::string opt = argvs[0][0];
pstd::StringToLower(opt);
bool is_slow_cmd = g_pika_conf->is_slow_cmd(opt);
bool is_monitor_cmd = g_pika_conf->is_admin_cmd(opt);
g_pika_server->ScheduleClientPool(&DoBackgroundTask, arg, is_slow_cmd, is_monitor_cmd);
bool is_admin_cmd = g_pika_conf->is_admin_cmd(opt);
g_pika_server->ScheduleClientPool(&DoBackgroundTask, arg, is_slow_cmd, is_admin_cmd);
return;
}
BatchExecRedisCmd(argvs);
Expand Down
8 changes: 7 additions & 1 deletion src/pika_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ int PikaConf::Load() {
GetConfStr("slow-cmd-list", &slow_cmd_list);
SetSlowCmd(slow_cmd_list);

std::string admin_cmd_list;
GetConfStr("admin-cmd-list", &admin_cmd_list);
if (admin_cmd_list == ""){
admin_cmd_list = "info, monitor, ping";
SetAdminCmd(admin_cmd_list);
}

GetConfInt("sync-thread-num", &sync_thread_num_);
if (sync_thread_num_ <= 0) {
sync_thread_num_ = 3;
Expand Down Expand Up @@ -772,7 +779,6 @@ int PikaConf::ConfigRewrite() {
SetConfInt("consensus-level", consensus_level_.load());
SetConfInt("replication-num", replication_num_.load());
SetConfStr("slow-cmd-list", pstd::Set2String(slow_cmd_set_, ','));
SetConfStr("admin-cmd-list", pstd::Set2String(admin_cmd_set_, ','));
SetConfInt("max-conn-rbuf-size", max_conn_rbuf_size_.load());
// options for storage engine
SetConfInt("max-cache-files", max_cache_files_);
Expand Down
4 changes: 2 additions & 2 deletions src/pika_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +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");
bool is_monitor_cmd = false;
g_pika_server->ScheduleClientPool(&ServeAndUnblockConns, args, is_slow_cmd, is_monitor_cmd);
bool is_admin_cmd = false;
g_pika_server->ScheduleClientPool(&ServeAndUnblockConns, args, is_slow_cmd, is_admin_cmd);
}

void BlockingBaseCmd::ServeAndUnblockConns(void* args) {
Expand Down
6 changes: 3 additions & 3 deletions src/pika_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,12 @@ void PikaServer::SetFirstMetaSync(bool v) {
first_meta_sync_ = v;
}

void PikaServer::ScheduleClientPool(net::TaskFunc func, void* arg, bool is_slow_cmd, bool is_monitor_cmd) {
if (is_slow_cmd) {
void PikaServer::ScheduleClientPool(net::TaskFunc func, void* arg, bool is_slow_cmd, bool is_admin_cmd) {
if (is_slow_cmd && g_pika_conf->slow_cmd_pool()) {
pika_slow_cmd_thread_pool_->Schedule(func, arg);
return;
}
if (is_monitor_cmd) {
if (is_admin_cmd) {
pika_admin_cmd_thread_pool_->Schedule(func, arg);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions tools/pika-port/pika_port_3/migrator_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void MigratorThread::MigrateStringsDB() {
std::string cmd;

argv.push_back("SET");
argv.push_back(iter->key().ToString().c_str());
argv.push_back(parsed_strings_value.value().ToString().c_str());
argv.push_back(iter->key().ToString());
argv.push_back(parsed_strings_value.value().ToString());
if (ts != 0 && ttl > 0) {
argv.push_back("EX");
argv.push_back(std::to_string(ttl));
Expand Down

0 comments on commit 63ccac0

Please sign in to comment.