summaryrefslogtreecommitdiff
path: root/jstests/sharding/resharding_disallow_drop.js
diff options
context:
space:
mode:
authorJordi Serra Torrens <jordi.serra-torrens@mongodb.com>2022-01-07 08:35:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-07 09:03:20 +0000
commit86773e0404ac646ad94e510852c0274bb9257b42 (patch)
treecf75b947f96d4df6af6aa7b47e7f8f88d6cf9e02 /jstests/sharding/resharding_disallow_drop.js
parent774fe7d3a26749f9b71d17c8a5952ab412f3b2b0 (diff)
downloadmongo-86773e0404ac646ad94e510852c0274bb9257b42.tar.gz
SERVER-62064 Serialize resharding with other DDL operations on stepup
Diffstat (limited to 'jstests/sharding/resharding_disallow_drop.js')
-rw-r--r--jstests/sharding/resharding_disallow_drop.js52
1 files changed, 29 insertions, 23 deletions
diff --git a/jstests/sharding/resharding_disallow_drop.js b/jstests/sharding/resharding_disallow_drop.js
index 37dbca81c6c..144abd55b16 100644
--- a/jstests/sharding/resharding_disallow_drop.js
+++ b/jstests/sharding/resharding_disallow_drop.js
@@ -1,26 +1,17 @@
/**
* Tests that a drop can't happen while resharding is in progress.
- *
* @tags: [
+ * requires_fcv_53,
+ * featureFlagRecoverableShardsvrReshardCollectionCoordinator,
* ]
*/
(function() {
"use strict";
load("jstests/libs/fail_point_util.js");
-load('jstests/libs/parallel_shell_helpers.js');
-
-// Ensures that resharding has acquired the db and collection distLocks. The fact that the entry in
-// config.reshardingOperations exists guarantees that the distLocks have already been acquired.
-function awaitReshardingStarted() {
- assert.soon(() => {
- const coordinatorDoc = st.s.getCollection("config.reshardingOperations").findOne({ns: ns});
- return coordinatorDoc !== null;
- }, "resharding didn't start");
-}
var st = new ShardingTest({
- shards: 1,
+ shards: {rs0: {nodes: 2}},
config: 1,
mongos: 1,
other: {
@@ -36,21 +27,36 @@ const db = st.s.getDB(dbName);
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}}));
-const pauseCoordinatorBeforeDecisionPersistedFailpoint = configureFailPoint(
- st.configRS.getPrimary(), "reshardingPauseCoordinatorBeforeDecisionPersisted");
+const reshardingPauseBeforeInsertCoordinatorDocFailpoint =
+ configureFailPoint(st.configRS.getPrimary(), "pauseBeforeInsertCoordinatorDoc");
+
+assert.commandFailedWithCode(
+ db.adminCommand({reshardCollection: ns, key: {newKey: 1}, maxTimeMS: 1000}),
+ ErrorCodes.MaxTimeMSExpired);
+
+// Wait for resharding to start running on the configsvr
+reshardingPauseBeforeInsertCoordinatorDocFailpoint.wait();
+
+// Drop cannot progress while resharding is in progress
+assert.commandFailedWithCode(db.runCommand({drop: collName, maxTimeMS: 5000}),
+ ErrorCodes.MaxTimeMSExpired);
-const awaitReshardResult = startParallelShell(
- funWithArgs(function(ns) {
- assert.commandWorked(db.adminCommand({reshardCollection: ns, key: {newKey: 1}}));
- }, ns), st.s.port);
+// Stepdown the DB primary shard
+const shard0Primary = st.rs0.getPrimary();
+assert.commandWorked(
+ shard0Primary.adminCommand({replSetStepDown: ReplSetTest.kForeverSecs, force: true}));
+st.rs0.awaitNodesAgreeOnPrimary();
-awaitReshardingStarted();
+// Even after stepdown, drop cannot progress due to the in-progress resharding
+assert.commandFailedWithCode(db.runCommand({drop: collName, maxTimeMS: 5000}),
+ ErrorCodes.MaxTimeMSExpired);
-let res = db.runCommand({drop: collName, maxTimeMS: 5000});
-assert(ErrorCodes.isExceededTimeLimitError(res.code));
+// Finish resharding
+reshardingPauseBeforeInsertCoordinatorDocFailpoint.off();
+assert.commandWorked(db.adminCommand({reshardCollection: ns, key: {newKey: 1}}));
-pauseCoordinatorBeforeDecisionPersistedFailpoint.off();
-awaitReshardResult();
+// Now the drop can complete
+assert.commandWorked(db.runCommand({drop: collName}));
st.stop();
})();