Commit ad3bca1f authored by antirez's avatar antirez
Browse files

Cluster: added stub for verifyClusterConfigWithData().

See the top-comment for the function in this commit for details about
what the function is supposed to do.
parent 1abce146
......@@ -1276,6 +1276,32 @@ void clusterUpdateState(void) {
}
}
/* This function is called after the node startup in order to verify that data
* loaded from disk is in agreement with the cluster configuration:
*
* 1) If we find keys about hash slots we have no responsibility for, the
* following happens:
* A) If no other node is in charge according to the current cluster
* configuration, we add these slots to our node.
* B) If according to our config other nodes are already in charge for
* this lots, we set the slots as IMPORTING from our point of view
* in order to justify we have those slots, and in order to make
* redis-trib aware of the issue, so that it can try to fix it.
* 2) If we find data in a DB different than DB0 we return REDIS_ERR to
* signal the caller it should quit the server with an error message
* or take other actions.
*
* The function always returns REDIS_OK even if it will try to correct
* the error described in "1". However if data is found in DB different
* from DB0, REDIS_ERR is returned.
*
* The function also uses the logging facility in order to warn the user
* about desynchronizations between the data we have in memory and the
* cluster configuration. */
int verifyClusterConfigWithData(void) {
return REDIS_OK;
}
/* -----------------------------------------------------------------------------
* CLUSTER command
* -------------------------------------------------------------------------- */
......
......@@ -2741,6 +2741,14 @@ int main(int argc, char **argv) {
linuxOvercommitMemoryWarning();
#endif
loadDataFromDisk();
if (server.cluster_enabled) {
if (verifyClusterConfigWithData() == REDIS_ERR) {
redisLog(REDIS_WARNING,
"You can't have keys in a DB different than DB 0 when in "
"Cluster mode. Exiting.");
exit(1);
}
}
if (server.ipfd > 0)
redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port);
if (server.sofd > 0)
......
......@@ -1227,6 +1227,7 @@ int selectDb(redisClient *c, int id);
void signalModifiedKey(redisDb *db, robj *key);
void signalFlushedDb(int dbid);
unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count);
int verifyClusterConfigWithData(void);
/* API to get key arguments from commands */
#define REDIS_GETKEYS_ALL 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment