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 fcf3b7bc feat(conn): allow CONFIG in stale-data replica (#2677)
fcf3b7bc is described below

commit fcf3b7bc80fd5e64c484a133d897db68dcdb0445
Author: Twice <[email protected]>
AuthorDate: Sat Nov 23 21:12:53 2024 +0800

    feat(conn): allow CONFIG in stale-data replica (#2677)
---
 src/server/redis_connection.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/server/redis_connection.cc b/src/server/redis_connection.cc
index 2e4ed68c..092df73d 100644
--- a/src/server/redis_connection.cc
+++ b/src/server/redis_connection.cc
@@ -366,6 +366,10 @@ static bool IsCmdForIndexing(uint64_t cmd_flags, 
CommandCategory cmd_cat) {
          (cmd_cat == CommandCategory::Hash || cmd_cat == CommandCategory::JSON 
|| cmd_cat == CommandCategory::Key);
 }
 
+static bool IsCmdAllowedInStaleData(const std::string &cmd_name) {
+  return cmd_name == "info" || cmd_name == "slaveof" || cmd_name == "config";
+}
+
 void Connection::ExecuteCommands(std::deque<CommandTokens> *to_process_cmds) {
   const Config *config = srv_->GetConfig();
   std::string reply;
@@ -479,7 +483,7 @@ void Connection::ExecuteCommands(std::deque<CommandTokens> 
*to_process_cmds) {
       continue;
     }
 
-    if (!config->slave_serve_stale_data && srv_->IsSlave() && cmd_name != 
"info" && cmd_name != "slaveof" &&
+    if (!config->slave_serve_stale_data && srv_->IsSlave() && 
!IsCmdAllowedInStaleData(cmd_name) &&
         srv_->GetReplicationState() != kReplConnected) {
       Reply(redis::Error({Status::RedisMasterDown,
                           "Link with MASTER is down "

Reply via email to