blob: 8a0730b79efe8ebf06ca6b66db9dbe5e12b897d2 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Test that 'notablescan' parameter does not affect queries internal namespaces.
// @tags: [uses_transactions]
(function() {
"use strict";
const dbName = "test";
const collName = "coll";
function runTests(ServerType) {
const s = new ServerType();
const configDB = s.getConn().getDB("config");
const session = s.getConn().getDB(dbName).getMongo().startSession();
const primaryDB = session.getDatabase(dbName);
// Implicitly create the collection outside of the transaction.
assert.commandWorked(primaryDB.getCollection(collName).insert({x: 1}));
// Run a transaction so the 'config.transactions' collection is implicitly created.
session.startTransaction();
assert.commandWorked(primaryDB.getCollection(collName).insert({x: 2}));
assert.commandWorked(session.commitTransaction_forTesting());
// Run a predicate query that would fail if we did not ignore the 'notablescan' flag.
assert.eq(configDB.transactions.find({any_nonexistent_field: {$exists: true}}).itcount(), 0);
// Run the same query against the user created collection honoring the 'notablescan' flag.
// This will cause the query to fail as there is no viable query plan. Unfortunately,
// the reported query error code is the cryptic 'BadValue'.
assert.commandFailedWithCode(
primaryDB.runCommand({find: collName, filter: {any_nonexistent_field: {$exists: true}}}),
ErrorCodes.BadValue);
s.stop();
}
function Sharding() {
this.st = new ShardingTest({
shards: 2,
config: 1,
other: {
shardOptions: {setParameter: {notablescan: true}},
configOptions: {setParameter: {notablescan: true}}
}
});
}
Sharding.prototype.stop = function() {
this.st.stop();
};
Sharding.prototype.getConn = function() {
return this.st.s0;
};
function ReplSet() {
this.rst = new ReplSetTest({nodes: 1, nodeOptions: {setParameter: {notablescan: true}}});
this.rst.startSet();
this.rst.initiate();
}
ReplSet.prototype.stop = function() {
this.rst.stopSet();
};
ReplSet.prototype.getConn = function() {
return this.rst.getPrimary();
};
[ReplSet, Sharding].forEach(runTests);
}());
|