1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

fix: prohibit read commands during takeover (#4267)

This commit is contained in:
Borys 2024-12-09 13:02:15 +02:00 committed by GitHub
parent 330d007d56
commit 51e16b2ceb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1056,7 +1056,11 @@ std::optional<ErrorReply> Service::VerifyCommandState(const CommandId* cid, CmdA
allowed_by_state = false; allowed_by_state = false;
break; break;
case GlobalState::TAKEN_OVER: 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; break;
default: default:
break; break;