From 3cf6f1f54fb3a31fb7157ab54919455feda41466 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 26 Mar 2014 12:29:43 +0100 Subject: [PATCH] Cluster: clusterHandleConfigEpochCollision() fixed. New config epochs must always be obtained incrementing the currentEpoch, that is itself guaranteed to be >= the max configEpoch currently known to the node. --- src/cluster.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index fa1b0f40..f29b8db8 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1235,11 +1235,12 @@ void clusterHandleConfigEpochCollision(clusterNode *sender) { /* Don't act if the colliding node has a smaller Node ID. */ if (memcmp(sender->name,myself->name,REDIS_CLUSTER_NAMELEN) <= 0) return; /* Get the next ID available at the best of this node knowledge. */ - myself->configEpoch = clusterGetMaxEpoch()+1; + server.cluster->currentEpoch++; + myself->configEpoch = server.cluster->currentEpoch; clusterSaveConfigOrDie(1); redisLog(REDIS_VERBOSE, "WARNING: configEpoch collision with node %.40s." - "Updating my configEpoch to %llu", + " Updating my configEpoch to %llu", sender->name, (unsigned long long) myself->configEpoch); } @@ -3343,6 +3344,9 @@ void clusterCommand(redisClient *c) { server.cluster->currentEpoch++; myself->configEpoch = server.cluster->currentEpoch; clusterDoBeforeSleep(CLUSTER_TODO_FSYNC_CONFIG); + redisLog(REDIS_WARNING, + "configEpoch set to %llu after importing slot %d", + (unsigned long long) myself->configEpoch, slot); } server.cluster->importing_slots_from[slot] = NULL; }