This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new dbd5f8d5 Make special exclusive command check a function (#1638)
dbd5f8d5 is described below
commit dbd5f8d50bb6710bdfc4ea2950b0eadb7a333883
Author: Twice <[email protected]>
AuthorDate: Sun Aug 6 16:12:20 2023 +0800
Make special exclusive command check a function (#1638)
---
src/server/redis_connection.cc | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/server/redis_connection.cc b/src/server/redis_connection.cc
index 6540b5b3..70f199d8 100644
--- a/src/server/redis_connection.cc
+++ b/src/server/redis_connection.cc
@@ -27,6 +27,7 @@
#include "commands/commander.h"
#include "fmt/format.h"
+#include "string_util.h"
#ifdef ENABLE_OPENSSL
#include <event2/bufferevent_ssl.h>
#endif
@@ -289,6 +290,13 @@ void Connection::RecordProfilingSampleIfNeed(const
std::string &cmd, uint64_t du
svr_->GetPerfLog()->PushEntry(std::move(entry));
}
+bool IsSpecialExclusiveCommand(const std::string &cmd_name, const
std::vector<std::string> &cmd_tokens,
+ Config *config) {
+ return (cmd_name == "config" && cmd_tokens.size() == 2 &&
util::EqualICase(cmd_tokens[1], "set")) ||
+ (config->cluster_enabled && (cmd_name == "clusterx" || cmd_name ==
"cluster") && cmd_tokens.size() >= 2 &&
+ Cluster::SubCommandIsExecExclusive(cmd_tokens[1]));
+}
+
void Connection::ExecuteCommands(std::deque<CommandTokens> *to_process_cmds) {
Config *config = svr_->GetConfig();
std::string reply, password = config->requirepass;
@@ -330,10 +338,7 @@ void Connection::ExecuteCommands(std::deque<CommandTokens>
*to_process_cmds) {
// Otherwise, we just use 'ConcurrencyGuard' to allow all workers to
execute commands at the same time.
if (IsFlagEnabled(Connection::kMultiExec) && attributes->name != "exec") {
// No lock guard, because 'exec' command has acquired
'WorkExclusivityGuard'
- } else if (attributes->IsExclusive() ||
- (cmd_name == "config" && cmd_tokens.size() == 2 &&
!strcasecmp(cmd_tokens[1].c_str(), "set")) ||
- (config->cluster_enabled && (cmd_name == "clusterx" || cmd_name
== "cluster") &&
- cmd_tokens.size() >= 2 &&
Cluster::SubCommandIsExecExclusive(cmd_tokens[1]))) {
+ } else if (attributes->IsExclusive() ||
IsSpecialExclusiveCommand(cmd_name, cmd_tokens, config)) {
exclusivity = svr_->WorkExclusivityGuard();
// When executing lua script commands that have "exclusive" attribute,
we need to know current connection,