blob: 85dcda1b8e1d13ecb9b47edbbf234fbe17160d37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/**
* Test that drop collection only takes database IX lock and will not be blocked by transactions.
*
* @tags: [uses_transactions, requires_db_locking, assumes_unsharded_collection]
*/
(function() {
"use strict";
let rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
let db = rst.getPrimary().getDB("test");
assert.commandWorked(db.runCommand({insert: "a", documents: [{x: 1}]}));
assert.commandWorked(db.runCommand({insert: "b", documents: [{x: 1}]}));
const session = db.getMongo().startSession();
const sessionDb = session.getDatabase("test");
session.startTransaction();
// This holds a database IX lock and a collection IX lock on "a".
sessionDb.a.insert({y: 1});
// This only requires database IX lock.
assert.commandWorked(db.runCommand({drop: "b"}));
assert.commandWorked(session.commitTransaction_forTesting());
rst.stopSet();
})();
|