Skip to content

Commit

Permalink
Merge branch 'unstable' into replicaof
Browse files Browse the repository at this point in the history
  • Loading branch information
PragmaTwice authored Nov 23, 2024
2 parents 4f75216 + fcf3b7b commit ac36d12
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/redis_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 "
Expand Down

0 comments on commit ac36d12

Please sign in to comment.