Skip to content

Commit

Permalink
SERVER-20722 require journaling and rs pv1 with config servers
Browse files Browse the repository at this point in the history
  • Loading branch information
matt dannenberg committed Oct 8, 2015
1 parent f8308fd commit 0eccf94
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
2 changes: 2 additions & 0 deletions buildscripts/resmokeconfig/suites/replica_sets_legacy.yml
Expand Up @@ -2,6 +2,8 @@ selector:
js_test:
roots:
- jstests/replsets/*.js
exclude_files:
- jstests/replsets/config_server_checks.js

executor:
js_test:
Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/mongod_options.cpp
Expand Up @@ -427,7 +427,8 @@ Status addMongodOptions(moe::OptionSection* options) {
"declare this is a config db of a cluster; default port 27019; "
"default dir /data/configdb")
.setSources(moe::SourceAllLegacy)
.incompatibleWith("shardsvr");
.incompatibleWith("shardsvr")
.incompatibleWith("nojournal");

sharding_options.addOptionChaining("sharding.configsvrMode",
"configsvrMode",
Expand Down
3 changes: 3 additions & 0 deletions src/mongo/db/repl/replica_set_config.cpp
Expand Up @@ -451,6 +451,9 @@ Status ReplicaSetConfig::validate() const {
}

if (_configServer) {
if (_protocolVersion == 0) {
return Status(ErrorCodes::BadValue, "Config servers cannot run in protocolVersion 0");
}
if (arbiterCount > 0) {
return Status(ErrorCodes::BadValue,
"Arbiters are not allowed in replica set configurations being used for "
Expand Down
52 changes: 36 additions & 16 deletions src/mongo/db/repl/replica_set_config_test.cpp
Expand Up @@ -732,11 +732,12 @@ TEST(ReplicaSetConfig, ChainingAllowedField) {

TEST(ReplicaSetConfig, ConfigServerField) {
ReplicaSetConfig config;
ASSERT_OK(config.initialize(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_OK(
config.initialize(BSON("_id"
<< "rs0"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
<< "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")))));
ASSERT_TRUE(config.isConfigServer());

ReplicaSetConfig config2;
Expand Down Expand Up @@ -1107,11 +1108,28 @@ TEST(ReplicaSetConfig, CheckBeyondMaximumNodesFailsValidate) {
ASSERT_TRUE(configA == configB);
}

TEST(ReplicaSetConfig, CheckConfigServerCantBeProtocolVersion0) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
<< "protocolVersion" << 0 << "version" << 1 << "configsvr"
<< true << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
<< "arbiterOnly" << true)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "cannot run in protocolVersion 0");
}

TEST(ReplicaSetConfig, CheckConfigServerCantHaveArbiters) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr"
<< true << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
Expand All @@ -1126,7 +1144,8 @@ TEST(ReplicaSetConfig, CheckConfigServerMustBuildIndexes) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr"
<< true << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
Expand All @@ -1140,15 +1159,16 @@ TEST(ReplicaSetConfig, CheckConfigServerMustBuildIndexes) {

TEST(ReplicaSetConfig, CheckConfigServerCantHaveSlaveDelay) {
ReplicaSetConfig configA;
ASSERT_OK(configA.initialize(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
<< "priority" << 0 << "slaveDelay"
<< 3)))));
ASSERT_OK(
configA.initialize(BSON("_id"
<< "rs0"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
<< "members" << BSON_ARRAY(BSON("_id" << 0 << "host"
<< "localhost:12345")
<< BSON("_id" << 1 << "host"
<< "localhost:54321"
<< "priority" << 0
<< "slaveDelay" << 3)))));
Status status = configA.validate();
ASSERT_EQUALS(ErrorCodes::BadValue, status);
ASSERT_STRING_CONTAINS(status.reason(), "cannot have a non-zero slaveDelay");
Expand Down
9 changes: 6 additions & 3 deletions src/mongo/db/repl/topology_coordinator_impl_test.cpp
Expand Up @@ -4958,7 +4958,8 @@ TEST_F(TopoCoordTest, GetMemberStateConfigSvrNoReadCommitted) {

updateConfig(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
Expand All @@ -4978,7 +4979,8 @@ TEST_F(TopoCoordTest, GetMemberStateConfigSvrNoReadCommittedButInSCCCMode) {

updateConfig(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
Expand All @@ -5001,7 +5003,8 @@ TEST_F(TopoCoordTest, GetMemberStateValidConfigSvr) {

updateConfig(BSON("_id"
<< "rs0"
<< "version" << 1 << "configsvr" << true << "members"
<< "protocolVersion" << 1 << "version" << 1 << "configsvr" << true
<< "members"
<< BSON_ARRAY(BSON("_id" << 10 << "host"
<< "hself")
<< BSON("_id" << 20 << "host"
Expand Down

0 comments on commit 0eccf94

Please sign in to comment.