summaryrefslogtreecommitdiff
path: root/src/redis-trib.rb
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-05-12 11:06:37 +0200
committerantirez <antirez@gmail.com>2014-05-12 11:06:37 +0200
commit658ad301ccb2876f316b8b6095e21ee855cd6e6e (patch)
treeb7fc4134224c8e5d8f7ef736610bd90da8184b75 /src/redis-trib.rb
parent63d1f9e570a80f73e56d02384307b3d4f6355daf (diff)
downloadredis-658ad301ccb2876f316b8b6095e21ee855cd6e6e.tar.gz
redis-trib create: use CONFIG SET-CONFIG-EPOCH before joining the cluster.
This way there is no need for the conflict resolution algo to be used in order to start with a cluster where each node has a different configEpoch.
Diffstat (limited to 'src/redis-trib.rb')
-rwxr-xr-xsrc/redis-trib.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index 92663eda8..be4b469cb 100755
--- a/src/redis-trib.rb
+++ b/src/redis-trib.rb
@@ -609,6 +609,22 @@ class RedisTrib
}
end
+ # Redis Cluster config epoch collision resolution code is able to eventually
+ # set a different epoch to each node after a new cluster is created, but
+ # it is slow compared to assign a progressive config epoch to each node
+ # before joining the cluster. However we do just a best-effort try here
+ # since if we fail is not a problem.
+ def assign_config_epoch
+ config_epoch = 1
+ @nodes.each{|n|
+ begin
+ n.r.cluster("set-config-epoch",config_epoch)
+ rescue
+ end
+ config_epoch += 1
+ }
+ end
+
def join_cluster
# We use a brute force approach to make sure the node will meet
# each other, that is, sending CLUSTER MEET messages to all the nodes
@@ -850,6 +866,8 @@ class RedisTrib
yes_or_die "Can I set the above configuration?"
flush_nodes_config
xputs ">>> Nodes configuration updated"
+ xputs ">>> Assign a different config epoch to each node"
+ assign_config_epoch
xputs ">>> Sending CLUSTER MEET messages to join the cluster"
join_cluster
# Give one second for the join to start, in order to avoid that