summaryrefslogtreecommitdiff
path: root/jstests/sharding
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-04-14 16:33:28 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-14 20:46:13 +0000
commit091c38c8b87d3276dd8b13e7425693493ea29cea (patch)
treeb36a37a50c42ac9fb2abefc5192bda898d39e122 /jstests/sharding
parent17e551b4393f606d308ab5c9fe555627498b0f3d (diff)
downloadmongo-091c38c8b87d3276dd8b13e7425693493ea29cea.tar.gz
SERVER-47324 Skip dassert when index commands from non-internal clients abort migrations
Diffstat (limited to 'jstests/sharding')
-rw-r--r--jstests/sharding/move_chunk_critical_section_non_internal_client_abort.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/sharding/move_chunk_critical_section_non_internal_client_abort.js b/jstests/sharding/move_chunk_critical_section_non_internal_client_abort.js
new file mode 100644
index 00000000000..0ecdee3bf41
--- /dev/null
+++ b/jstests/sharding/move_chunk_critical_section_non_internal_client_abort.js
@@ -0,0 +1,41 @@
+/**
+ * Tests that a moveChunk operation is properly aborted when an index command is received from a
+ * non-internal client while in the critical section.
+ */
+(function() {
+"use strict";
+
+load('jstests/libs/parallel_shell_helpers.js');
+
+const dbName = "test";
+const collName = "move_chunk_critical_section_non_internal_client_abort";
+const ns = dbName + "." + collName;
+
+const st = new ShardingTest({shards: 2});
+
+assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
+assert.commandWorked(st.s.adminCommand({movePrimary: dbName, to: st.shard0.shardName}));
+
+assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({_id: 0}));
+assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({_id: 1}));
+assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}}));
+
+// Pause the moveChunk while it is in the critical section.
+const fp = configureFailPoint(st.shard0, "moveChunkHangAtStep5");
+const awaitResult =
+ startParallelShell(funWithArgs(function(ns, toShardName) {
+ assert.commandFailedWithCode(
+ db.adminCommand({moveChunk: ns, find: {_id: 0}, to: toShardName}),
+ ErrorCodes.Interrupted);
+ }, ns, st.shard1.shardName), st.s.port);
+fp.wait();
+
+// Perform a collMod directly on the shard's primary to cause the moveChunk to abort.
+assert.commandWorked(
+ st.rs0.getPrimary().getDB(dbName).runCommand({collMod: collName, writeConcern: {w: 1}}));
+
+fp.off();
+awaitResult();
+
+st.stop();
+})(); \ No newline at end of file