Skip to content

Commit bdc23b9

Browse files
committed
SERVER-42118 Fix configurations for finer-grained DDL locking tests
1 parent dd29b01 commit bdc23b9

File tree

3 files changed

+31
-36
lines changed

3 files changed

+31
-36
lines changed

jstests/core/txns/create_collection_not_blocked_by_txn.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@
77
(function() {
88
"use strict";
99

10-
let rst = new ReplSetTest({nodes: 1});
11-
rst.startSet();
12-
rst.initiate();
10+
let dbName = 'create_collection_not_blocked_by_txn';
11+
let mydb = db.getSiblingDB(dbName);
1312

14-
let db = rst.getPrimary().getDB("test");
13+
mydb.a.drop({writeConcern: {w: "majority"}});
14+
mydb.b.drop({writeConcern: {w: "majority"}});
15+
mydb.c.drop({writeConcern: {w: "majority"}});
1516

16-
assert.commandWorked(db.runCommand({insert: "a", documents: [{x: 1}]}));
17+
assert.commandWorked(mydb.runCommand({insert: "a", documents: [{x: 1}]}));
1718

18-
const session = db.getMongo().startSession();
19-
const sessionDb = session.getDatabase("test");
19+
const session = mydb.getMongo().startSession();
20+
const sessionDb = session.getDatabase(dbName);
2021

2122
session.startTransaction();
2223
// This holds a database IX lock and a collection IX lock on "a".
2324
sessionDb.a.insert({y: 1});
2425

2526
// This only requires database IX lock.
26-
assert.commandWorked(db.createCollection("b"));
27+
assert.commandWorked(mydb.createCollection("b"));
2728
// Implicit creation.
28-
assert.commandWorked(db.runCommand({insert: "c", documents: [{x: 2}]}));
29+
assert.commandWorked(mydb.runCommand({insert: "c", documents: [{x: 2}]}));
2930

3031
assert.commandWorked(session.commitTransaction_forTesting());
31-
32-
rst.stopSet();
3332
})();

jstests/core/txns/drop_collection_not_blocked_by_txn.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,21 @@
77
(function() {
88
"use strict";
99

10-
let rst = new ReplSetTest({nodes: 1});
11-
rst.startSet();
12-
rst.initiate();
10+
let dbName = 'drop_collection_not_blocked_by_txn';
11+
let mydb = db.getSiblingDB(dbName);
1312

14-
let db = rst.getPrimary().getDB("test");
13+
assert.commandWorked(mydb.runCommand({insert: "a", documents: [{x: 1}]}));
14+
assert.commandWorked(mydb.runCommand({insert: "b", documents: [{x: 1}]}));
1515

16-
assert.commandWorked(db.runCommand({insert: "a", documents: [{x: 1}]}));
17-
assert.commandWorked(db.runCommand({insert: "b", documents: [{x: 1}]}));
18-
19-
const session = db.getMongo().startSession();
20-
const sessionDb = session.getDatabase("test");
16+
const session = mydb.getMongo().startSession();
17+
const sessionDb = session.getDatabase(dbName);
2118

2219
session.startTransaction();
2320
// This holds a database IX lock and a collection IX lock on "a".
2421
sessionDb.a.insert({y: 1});
2522

2623
// This only requires database IX lock.
27-
assert.commandWorked(db.runCommand({drop: "b"}));
24+
assert.commandWorked(mydb.runCommand({drop: "b"}));
2825

2926
assert.commandWorked(session.commitTransaction_forTesting());
30-
31-
rst.stopSet();
3227
})();

jstests/core/txns/rename_collection_not_blocked_by_txn.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@
77
(function() {
88
"use strict";
99

10-
let rst = new ReplSetTest({nodes: 1});
11-
rst.startSet();
12-
rst.initiate();
10+
let dbName = 'rename_collection_not_blocked_by_txn';
11+
let mydb = db.getSiblingDB(dbName);
1312

14-
let db = rst.getPrimary().getDB("test");
13+
mydb.t.drop({writeConcern: {w: "majority"}});
14+
mydb.a.drop({writeConcern: {w: "majority"}});
15+
mydb.b.drop({writeConcern: {w: "majority"}});
16+
mydb.c.drop({writeConcern: {w: "majority"}});
1517

16-
assert.commandWorked(db.runCommand({insert: "t", documents: [{x: 1}]}));
17-
assert.commandWorked(db.runCommand({insert: "a", documents: [{x: 1}]}));
18-
assert.commandWorked(db.runCommand({insert: "b", documents: [{x: 1}]}));
18+
assert.commandWorked(mydb.runCommand({insert: "t", documents: [{x: 1}]}));
19+
assert.commandWorked(mydb.runCommand({insert: "a", documents: [{x: 1}]}));
20+
assert.commandWorked(mydb.runCommand({insert: "b", documents: [{x: 1}]}));
1921

20-
const session = db.getMongo().startSession();
21-
const sessionDb = session.getDatabase("test");
22+
const session = mydb.getMongo().startSession();
23+
const sessionDb = session.getDatabase(dbName);
2224

2325
session.startTransaction();
2426
// This holds a database IX lock and a collection IX lock on "test.t".
2527
sessionDb.t.insert({y: 1});
2628

2729
// This only requires database IX lock.
28-
assert.commandWorked(db.adminCommand({renameCollection: "test.a", to: "test.b", dropTarget: true}));
29-
assert.commandWorked(db.adminCommand({renameCollection: "test.b", to: "test.c"}));
30+
assert.commandWorked(
31+
mydb.adminCommand({renameCollection: dbName + ".a", to: dbName + ".b", dropTarget: true}));
32+
assert.commandWorked(mydb.adminCommand({renameCollection: dbName + ".b", to: dbName + ".c"}));
3033

3134
assert.commandWorked(session.commitTransaction_forTesting());
32-
33-
rst.stopSet();
3435
})();

0 commit comments

Comments
 (0)