summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-02-11 10:00:11 +0100
committerantirez <antirez@gmail.com>2014-02-11 10:21:55 +0100
commit585e9fb8867d8fa393de4a27f951971f72eb4355 (patch)
tree0cecdf6d7ccdf64e22db767e11fd609940240692 /src
parent8b5196addff8cbfef71da72715bc2569451d0a30 (diff)
downloadredis-585e9fb8867d8fa393de4a27f951971f72eb4355.tar.gz
Cluster: clusterSetStartupEpoch() made more generally useful.
The actual goal of the function was to get the max configEpoch found in the cluster, so make it general by removing the assignment of the max epoch to currentEpoch that is useful only at startup.
Diffstat (limited to 'src')
-rw-r--r--src/cluster.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/cluster.c b/src/cluster.c
index febd1888d..aeedc1774 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -73,21 +73,19 @@ void resetManualFailover(void);
* Initialization
* -------------------------------------------------------------------------- */
-/* This function is called at startup in order to set the currentEpoch
- * (which is not saved on permanent storage) to the greatest configEpoch found
- * in the loaded nodes (configEpoch is stored on permanent storage as soon as
- * it changes for some node). */
-void clusterSetStartupEpoch() {
+/* Return the greatest configEpoch found in the cluster. */
+uint64_t clusterGetMaxEpoch(void) {
+ uint64_t max = 0;
dictIterator *di;
dictEntry *de;
di = dictGetSafeIterator(server.cluster->nodes);
while((de = dictNext(di)) != NULL) {
clusterNode *node = dictGetVal(de);
- if (node->configEpoch > server.cluster->currentEpoch)
- server.cluster->currentEpoch = node->configEpoch;
+ if (node->configEpoch > max) max = node->configEpoch;
}
dictReleaseIterator(di);
+ return max;
}
int clusterLoadConfig(char *filename) {
@@ -227,7 +225,10 @@ int clusterLoadConfig(char *filename) {
/* Config sanity check */
redisAssert(server.cluster->myself != NULL);
redisLog(REDIS_NOTICE,"Node configuration loaded, I'm %.40s", myself->name);
- clusterSetStartupEpoch();
+ /* Set the currentEpoch to the max epoch found in the master.
+ * FIXME: this should actually be part of the persistent state, as
+ * documented in the Github issue #1479. */
+ server.cluster->currentEpoch = clusterGetMaxEpoch();
return REDIS_OK;
fmterr: