(function() {
|
const rst = new ReplSetTest({nodes: 1});
|
rst.startSet();
|
rst.initiate();
|
const session = rst.getPrimary().getDB("test").getMongo().startSession();
|
const db1 = session.getDatabase("test1");
|
const db2 = session.getDatabase("test2");
|
|
// Populate two collections in different databases.
|
for (let i = 0; i < 4; i++) {
|
assert.commandWorked(db1.coll.insert({_id: i}, {writeConcern: {w: "majority"}}));
|
assert.commandWorked(db2.coll.insert({_id: i}, {writeConcern: {w: "majority"}}));
|
}
|
|
// Open a snapshot read cursor on db1.coll.
|
let res = assert.commandWorked(db1.runCommand(
|
{find: "coll", batchSize: 2, readConcern: {level: "snapshot"}, txnNumber: NumberLong(0)}));
|
|
// Open a snapshot read cursor on db2.coll.
|
res = assert.commandWorked(db2.runCommand(
|
{find: "coll", batchSize: 2, readConcern: {level: "snapshot"}, txnNumber: NumberLong(1)}));
|
|
// db2.coll is not locked, so this drop succeeds, when it should fail.
|
db2.coll.drop();
|
rst.stopSet();
|
}());
|