Skip to content

Commit

Permalink
fix: prohibit read commands during takeover (#4267)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev authored Dec 9, 2024
1 parent 330d007 commit 51e16b2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,11 @@ std::optional<ErrorReply> Service::VerifyCommandState(const CommandId* cid, CmdA
allowed_by_state = false;
break;
case GlobalState::TAKEN_OVER:
allowed_by_state = !cid->IsWriteOnly();
// Only PING, admin commands, and all commands via admin connections are allowed
// we prohibit even read commands, because read commands running in pipeline can take a while
// to send all data to a client which leads to fail in takeover
allowed_by_state = dfly_cntx.conn()->IsPrivileged() || (cid->opt_mask() & CO::ADMIN) ||
cid->name() == "PING";
break;
default:
break;
Expand Down

0 comments on commit 51e16b2

Please sign in to comment.