summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/ignore_notablescan.js
diff options
context:
space:
mode:
authorMartin Neupauer <martin.neupauer@mongodb.com>2019-03-01 12:28:39 -0500
committerMartin Neupauer <martin.neupauer@mongodb.com>2019-03-05 09:36:03 -0500
commit18593fe22c55b7a51c44f04a39d30573b0b01873 (patch)
tree2b8ac015c430be832f0e6394be9da7fddf9705b6 /jstests/noPassthrough/ignore_notablescan.js
parenta39875e4e060d42a7ce70ec82b07af2850d3bab7 (diff)
downloadmongo-18593fe22c55b7a51c44f04a39d30573b0b01873.tar.gz
SERVER-39903 notablescan parameter should be ignored for internally used
namespaces
Diffstat (limited to 'jstests/noPassthrough/ignore_notablescan.js')
-rw-r--r--jstests/noPassthrough/ignore_notablescan.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/jstests/noPassthrough/ignore_notablescan.js b/jstests/noPassthrough/ignore_notablescan.js
new file mode 100644
index 00000000000..484d5bf5010
--- /dev/null
+++ b/jstests/noPassthrough/ignore_notablescan.js
@@ -0,0 +1,73 @@
+// 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.writeOK(primaryDB.getCollection(collName).insert({x: 1}));
+
+ // Run a transaction so the 'config.transactions' collection is implicitly created.
+ session.startTransaction();
+ assert.writeOK(primaryDB.getCollection(collName).insert({x: 2}));
+ session.commitTransaction();
+
+ // 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);
+}());