From 05fa4f403460d8121de05dfc0d377dbcbd3ab264 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 4 Apr 2013 12:29:10 +0200 Subject: [PATCH] Cluster: node timeout is now configurable. --- redis.conf | 6 ++++++ src/cluster.c | 2 +- src/config.c | 5 +++++ src/redis.c | 1 + src/redis.h | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/redis.conf b/redis.conf index f4b0af7e..9bcb130d 100644 --- a/redis.conf +++ b/redis.conf @@ -493,6 +493,12 @@ lua-time-limit 5000 # # cluster-config-file nodes-6379.conf +# Cluster node timeout is the amount of seconds a node must be unreachable +# for it to be considered in failure state. +# Most other internal time limits are multiplicators of the node timeout. +# +# cluster-node-timeout 15 + # In order to setup your cluster make sure to read the documentation # available at http://redis.io web site. diff --git a/src/cluster.c b/src/cluster.c index 98d37b28..2f412ae5 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -231,7 +231,7 @@ void clusterInit(void) { server.cluster->state = REDIS_CLUSTER_FAIL; server.cluster->size = 1; server.cluster->nodes = dictCreate(&clusterNodesDictType,NULL); - server.cluster->node_timeout = REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT; + server.cluster->node_timeout = server.cluster_node_timeout; server.cluster->failover_auth_time = 0; server.cluster->failover_auth_count = 0; memset(server.cluster->migrating_slots_to,0, diff --git a/src/config.c b/src/config.c index 98136fde..cb7de78b 100644 --- a/src/config.c +++ b/src/config.c @@ -387,6 +387,11 @@ void loadServerConfigFromString(char *config) { } else if (!strcasecmp(argv[0],"cluster-config-file") && argc == 2) { zfree(server.cluster_configfile); server.cluster_configfile = zstrdup(argv[1]); + } else if (!strcasecmp(argv[0],"cluster-node-timeout") && argc == 2) { + server.cluster_node_timeout = atoi(argv[1]); + if (server.cluster_node_timeout <= 0) { + err = "cluster node timeout must be 1 or greater"; goto loaderr; + } } else if (!strcasecmp(argv[0],"lua-time-limit") && argc == 2) { server.lua_time_limit = strtoll(argv[1],NULL,10); } else if (!strcasecmp(argv[0],"slowlog-log-slower-than") && diff --git a/src/redis.c b/src/redis.c index 6d5f3eec..d375d5bb 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1261,6 +1261,7 @@ void initServerConfig() { server.repl_ping_slave_period = REDIS_REPL_PING_SLAVE_PERIOD; server.repl_timeout = REDIS_REPL_TIMEOUT; server.cluster_enabled = 0; + server.cluster_node_timeout = REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT; server.cluster_configfile = zstrdup("nodes.conf"); server.lua_caller = NULL; server.lua_time_limit = REDIS_LUA_TIME_LIMIT; diff --git a/src/redis.h b/src/redis.h index 0d0f9a85..dddc7017 100644 --- a/src/redis.h +++ b/src/redis.h @@ -853,6 +853,7 @@ struct redisServer { xor of REDIS_NOTIFY... flags. */ /* Cluster */ int cluster_enabled; /* Is cluster enabled? */ + int cluster_node_timeout; /* Cluster node timeout. */ char *cluster_configfile; /* Cluster auto-generated config file name. */ clusterState *cluster; /* State of the cluster */ /* Scripting */