diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-04-11 08:14:05 -0400 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-04-11 08:19:41 -0400 |
commit | 9cf12644d6544c004f12bfc6e5f00d0d1681735e (patch) | |
tree | 749ec85706b082911c473b5cea6e8384754fdcb7 /jstests | |
parent | ffa171bc887edb1a08c06033f64b05cbe676cd7d (diff) | |
download | mongo-9cf12644d6544c004f12bfc6e5f00d0d1681735e.tar.gz |
SERVER-40436 Ensure that the 'collMod' command takes a database MODE_X lock during a no-op
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthroughWithMongod/coll_mod_takes_database_x_lock.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/coll_mod_takes_database_x_lock.js b/jstests/noPassthroughWithMongod/coll_mod_takes_database_x_lock.js new file mode 100644 index 00000000000..bf78d13f887 --- /dev/null +++ b/jstests/noPassthroughWithMongod/coll_mod_takes_database_x_lock.js @@ -0,0 +1,33 @@ +/** + * Ensures that the 'collMod' command takes a database MODE_X lock during a no-op. + */ +(function() { + 'use strict'; + + const failpoint = 'hangAfterDatabaseLock'; + assert.commandWorked(db.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn"})); + + const conn = db.getMongo(); + db.createCollection('foo'); + + // Run a no-op collMod command. + const awaitParallelShell = startParallelShell(() => { + assert.commandWorked(db.runCommand({collMod: 'foo'})); + }, conn.port); + + // Check that the database MODE_X lock is being held by checking in lockInfo. + assert.soon(() => { + let lockInfo = assert.commandWorked(db.adminCommand({lockInfo: 1})).lockInfo; + for (let i = 0; i < lockInfo.length; i++) { + let resourceId = lockInfo[i].resourceId; + if (resourceId.includes("Database") && resourceId.includes("test")) { + return true; + } + } + + return false; + }); + + assert.commandWorked(db.adminCommand({configureFailPoint: failpoint, mode: "off"})); + awaitParallelShell(); +})(); |