Unverified Commit cb1fff3c authored by llahav-amzn's avatar llahav-amzn Committed by GitHub
Browse files

In cluster-mode enabled, override the databases config at startup to 1 (#11555)



In cluster-mode, only DB0 is supported so all data must reside in that database. There is a single check that validates that data loaded from an RDB all resides in DB0. This check is performed after all the data is loaded which makes it difficult to identify where the non DB0 data resides as well as does a bunch of unnecessary work to load incompatible data. This change override the database config at startup to 1 to throw an error when attempting to add data to a database other than DB0.
Co-authored-by: default avatarEran Liberty <eranl@amazon.com>
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
Co-authored-by: default avatarMadelyn Olson <madelyneolson@gmail.com>
parent a2e75a78
......@@ -611,6 +611,12 @@ void loadServerConfigFromString(char *config) {
goto loaderr;
}
/* in case cluster mode is enabled dbnum must be 1 */
if (server.cluster_enabled && server.dbnum > 1) {
serverLog(LL_WARNING, "WARNING: Changing databases number from %d to 1 since we are in cluster mode", server.dbnum);
server.dbnum = 1;
}
/* To ensure backward compatibility and work while hz is out of range */
if (server.config_hz < CONFIG_MIN_HZ) server.config_hz = CONFIG_MIN_HZ;
if (server.config_hz > CONFIG_MAX_HZ) server.config_hz = CONFIG_MAX_HZ;
......
......@@ -7202,12 +7202,7 @@ int main(int argc, char **argv) {
aofOpenIfNeededOnServerStart();
aofDelHistoryFiles();
if (server.cluster_enabled) {
if (verifyClusterConfigWithData() == C_ERR) {
serverLog(LL_WARNING,
"You can't have keys in a DB different than DB 0 when in "
"Cluster mode. Exiting.");
exit(1);
}
serverAssert(verifyClusterConfigWithData() == C_OK);
}
for (j = 0; j < CONN_TYPE_MAX; j++) {
......
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