mirror of
https://github.com/fluencelabs/redis
synced 2025-06-14 09:41:21 +00:00
config option to select if when replication link with master a slave should or not serve stale data
This commit is contained in:
12
src/redis.c
12
src/redis.c
@ -786,6 +786,7 @@ void initServerConfig() {
|
||||
server.masterport = 6379;
|
||||
server.master = NULL;
|
||||
server.replstate = REDIS_REPL_NONE;
|
||||
server.repl_serve_stale_data = 1;
|
||||
|
||||
/* Double constants initialization */
|
||||
R_Zero = 0.0;
|
||||
@ -994,6 +995,17 @@ int processCommand(redisClient *c) {
|
||||
return REDIS_OK;
|
||||
}
|
||||
|
||||
/* Only allow INFO and SLAVEOF when slave-serve-stale-data is no and
|
||||
* we are a slave with a broken link with master. */
|
||||
if (server.masterhost && server.replstate != REDIS_REPL_CONNECTED &&
|
||||
server.repl_serve_stale_data == 0 &&
|
||||
cmd->proc != infoCommand && cmd->proc != slaveofCommand)
|
||||
{
|
||||
addReplyError(c,
|
||||
"link with MASTER is down and slave-serve-stale-data is set to no");
|
||||
return REDIS_OK;
|
||||
}
|
||||
|
||||
/* Exec the command */
|
||||
if (c->flags & REDIS_MULTI &&
|
||||
cmd->proc != execCommand && cmd->proc != discardCommand &&
|
||||
|
Reference in New Issue
Block a user