summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-04-24 16:40:06 -0400
committerBlake Oler <blake.oler@mongodb.com>2018-04-26 15:22:15 -0400
commitfb9e6ec91f45036266e9678e4806ca5cbb318164 (patch)
tree98871142f12831d0a1f867e57df20759c0c01d78
parent34333a94de7b68e6881c234a09ab9186a6ac3348 (diff)
downloadmongo-fb9e6ec91f45036266e9678e4806ca5cbb318164.tar.gz
SERVER-34649 Return a bad status when the MovePrimarySourceManager receives a bad return from commitMovePrimary
-rw-r--r--buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml1
-rw-r--r--buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards.yml1
-rw-r--r--buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml1
-rw-r--r--jstests/sharding/move_primary_fails_without_database_version.js19
-rw-r--r--src/mongo/db/s/move_primary_source_manager.cpp6
5 files changed, 28 insertions, 0 deletions
diff --git a/buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml b/buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml
index 37bbedbadfd..433e198f1ab 100644
--- a/buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml
@@ -82,6 +82,7 @@ selector:
- jstests/sharding/parallel.js
- jstests/sharding/migrateBig.js
- jstests/sharding/sharding_rs1.js
+ - jstests/sharding/move_primary_fails_without_database_version.js
# Calls the config server primary directly (not through mongos)
- jstests/sharding/configsvr_metadata_commands_require_majority_write_concern.js
- jstests/sharding/min_optime_recovery_on_successful_move_chunk_commit.js
diff --git a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards.yml b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards.yml
index 84821b463f6..43928e3d11f 100644
--- a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards.yml
@@ -31,6 +31,7 @@ selector:
- jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
- jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
- jstests/sharding/move_primary_basic.js
+ - jstests/sharding/move_primary_fails_without_database_version.js
- jstests/sharding/movePrimary1.js
- jstests/sharding/mongos_validate_writes.js
- jstests/sharding/resume_change_stream_on_subset_of_shards.js
diff --git a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml
index 70be10cf9f4..5157e0c189a 100644
--- a/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_last_stable_mongos_and_mixed_shards_misc.yml
@@ -39,6 +39,7 @@ selector:
- jstests/sharding/safe_secondary_reads_single_migration_suspend_range_deletion.js
- jstests/sharding/safe_secondary_reads_single_migration_waitForDelete.js
- jstests/sharding/move_primary_basic.js
+ - jstests/sharding/move_primary_fails_without_database_version.js
- jstests/sharding/movePrimary1.js
- jstests/sharding/mongos_validate_writes.js
- jstests/sharding/resume_change_stream_on_subset_of_shards.js
diff --git a/jstests/sharding/move_primary_fails_without_database_version.js b/jstests/sharding/move_primary_fails_without_database_version.js
new file mode 100644
index 00000000000..cf03d5e1cfe
--- /dev/null
+++ b/jstests/sharding/move_primary_fails_without_database_version.js
@@ -0,0 +1,19 @@
+// Tests that a movePrimary will fail if the database doesn't have a version in config.databases
+(function() {
+ "use strict";
+
+ const dbName = "test";
+
+ const st = new ShardingTest({shards: 2});
+
+ assert.commandWorked(st.s.getDB("config").getCollection("databases").insert({
+ _id: dbName,
+ partitioned: false,
+ primary: st.shard0.shardName
+ }));
+
+ assert.commandFailedWithCode(st.s.adminCommand({movePrimary: dbName, to: st.shard1.shardName}),
+ ErrorCodes.InternalError);
+
+ st.stop();
+})(); \ No newline at end of file
diff --git a/src/mongo/db/s/move_primary_source_manager.cpp b/src/mongo/db/s/move_primary_source_manager.cpp
index f6fa929fdff..be9b71863b2 100644
--- a/src/mongo/db/s/move_primary_source_manager.cpp
+++ b/src/mongo/db/s/move_primary_source_manager.cpp
@@ -266,6 +266,9 @@ Status MovePrimarySourceManager::commitOnConfig(OperationContext* opCtx) {
}
}
+ // We would not be able to guarantee our next database refresh would pick up the write for
+ // the movePrimary commit (if it happened), because we were unable to get the latest config
+ // OpTime.
fassert(50762,
validateStatus.withContext(
str::stream() << "Failed to commit movePrimary for database " << getNss().ns()
@@ -273,6 +276,9 @@ Status MovePrimarySourceManager::commitOnConfig(OperationContext* opCtx) {
<< redact(commitStatus)
<< ". Updating the optime with a write before clearing the "
<< "version also failed"));
+
+ // If we can validate but the commit still failed, return the status.
+ return commitStatus;
}
_state = kCommitted;