chore: Forbid replicating a replica (#3779)

* chore: Forbid replicating a replica

We do not support connecting a replica to a replica, but before this PR
we allowed doing so. This PR disables that behavior.

Fixes #3679

* `replicaof_mu_`
This commit is contained in:
Shahar Mike 2024-09-24 16:42:22 +03:00 committed by GitHub
parent 9aadc0cd2b
commit 526bce4222
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View file

@ -2839,6 +2839,13 @@ void ServerFamily::ReplTakeOver(CmdArgList args, ConnectionContext* cntx) {
}
void ServerFamily::ReplConf(CmdArgList args, ConnectionContext* cntx) {
{
util::fb2::LockGuard lk(replicaof_mu_);
if (!ServerState::tlocal()->is_master) {
return cntx->SendError("Replicating a replica is unsupported");
}
}
if (args.size() % 2 == 1)
goto err;
for (unsigned i = 0; i < args.size(); i += 2) {