summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js')
-rw-r--r--jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js131
1 files changed, 64 insertions, 67 deletions
diff --git a/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js b/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
index d8cd49f7995..3e855455985 100644
--- a/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
+++ b/jstests/noPassthrough/apply_ops_DDL_operation_does_not_take_global_X.js
@@ -5,75 +5,72 @@
*/
(function() {
- 'use strict';
+'use strict';
+
+const testDBName = 'test';
+const readDBName = 'read';
+const readCollName = 'readColl';
+const testCollName = 'testColl';
+const renameCollName = 'renameColl';
+
+const rst = new ReplSetTest({name: jsTestName(), nodes: 2});
+rst.startSet();
+rst.initiate();
+
+const primary = rst.getPrimary();
+const secondary = rst.getSecondary();
+
+assert.commandWorked(
+ primary.getDB(readDBName)
+ .runCommand({insert: readCollName, documents: [{x: 1}], writeConcern: {w: 2}}));
+
+// The find will hang and holds a global IS lock.
+assert.commandWorked(secondary.getDB("admin").runCommand(
+ {configureFailPoint: "waitInFindBeforeMakingBatch", mode: "alwaysOn"}));
+
+const findWait = startParallelShell(function() {
+ db.getMongo().setSlaveOk();
+ assert.eq(
+ db.getSiblingDB('read').getCollection('readColl').find().comment('read hangs').itcount(),
+ 1);
+}, secondary.port);
+
+assert.soon(function() {
+ let findOp = secondary.getDB('admin')
+ .aggregate([{$currentOp: {}}, {$match: {'command.comment': 'read hangs'}}])
+ .toArray();
+ return findOp.length == 1;
+});
+
+{
+ // Run a series of DDL commands, none of which should take the global X lock.
+ const testDB = primary.getDB(testDBName);
+ assert.commandWorked(testDB.runCommand({create: testCollName, writeConcern: {w: 2}}));
- const testDBName = 'test';
- const readDBName = 'read';
- const readCollName = 'readColl';
- const testCollName = 'testColl';
- const renameCollName = 'renameColl';
-
- const rst = new ReplSetTest({name: jsTestName(), nodes: 2});
- rst.startSet();
- rst.initiate();
+ assert.commandWorked(
+ testDB.runCommand({collMod: testCollName, validator: {v: 1}, writeConcern: {w: 2}}));
- const primary = rst.getPrimary();
- const secondary = rst.getSecondary();
+ assert.commandWorked(testDB.runCommand({
+ createIndexes: testCollName,
+ indexes: [{key: {x: 1}, name: 'x_1'}],
+ writeConcern: {w: 2}
+ }));
assert.commandWorked(
- primary.getDB(readDBName)
- .runCommand({insert: readCollName, documents: [{x: 1}], writeConcern: {w: 2}}));
-
- // The find will hang and holds a global IS lock.
- assert.commandWorked(secondary.getDB("admin").runCommand(
- {configureFailPoint: "waitInFindBeforeMakingBatch", mode: "alwaysOn"}));
-
- const findWait = startParallelShell(function() {
- db.getMongo().setSlaveOk();
- assert.eq(db.getSiblingDB('read')
- .getCollection('readColl')
- .find()
- .comment('read hangs')
- .itcount(),
- 1);
- }, secondary.port);
-
- assert.soon(function() {
- let findOp = secondary.getDB('admin')
- .aggregate([{$currentOp: {}}, {$match: {'command.comment': 'read hangs'}}])
- .toArray();
- return findOp.length == 1;
- });
-
- {
- // Run a series of DDL commands, none of which should take the global X lock.
- const testDB = primary.getDB(testDBName);
- assert.commandWorked(testDB.runCommand({create: testCollName, writeConcern: {w: 2}}));
-
- assert.commandWorked(
- testDB.runCommand({collMod: testCollName, validator: {v: 1}, writeConcern: {w: 2}}));
-
- assert.commandWorked(testDB.runCommand({
- createIndexes: testCollName,
- indexes: [{key: {x: 1}, name: 'x_1'}],
- writeConcern: {w: 2}
- }));
-
- assert.commandWorked(
- testDB.runCommand({dropIndexes: testCollName, index: 'x_1', writeConcern: {w: 2}}));
-
- assert.commandWorked(primary.getDB('admin').runCommand({
- renameCollection: testDBName + '.' + testCollName,
- to: testDBName + '.' + renameCollName,
- writeConcern: {w: 2}
- }));
-
- assert.commandWorked(testDB.runCommand({drop: renameCollName, writeConcern: {w: 2}}));
- }
-
- assert.commandWorked(secondary.getDB("admin").runCommand(
- {configureFailPoint: "waitInFindBeforeMakingBatch", mode: "off"}));
- findWait();
-
- rst.stopSet();
+ testDB.runCommand({dropIndexes: testCollName, index: 'x_1', writeConcern: {w: 2}}));
+
+ assert.commandWorked(primary.getDB('admin').runCommand({
+ renameCollection: testDBName + '.' + testCollName,
+ to: testDBName + '.' + renameCollName,
+ writeConcern: {w: 2}
+ }));
+
+ assert.commandWorked(testDB.runCommand({drop: renameCollName, writeConcern: {w: 2}}));
+}
+
+assert.commandWorked(secondary.getDB("admin").runCommand(
+ {configureFailPoint: "waitInFindBeforeMakingBatch", mode: "off"}));
+findWait();
+
+rst.stopSet();
})();