summaryrefslogtreecommitdiff
path: root/jstests/core/ord.js
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2021-02-23 19:24:05 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-08 21:42:41 +0000
commitaff08f0357b29a7ab03bd7d548c8c677ad0432c7 (patch)
tree94e685f0bf031ebb5812b0a03ce42ee43c7d0433 /jstests/core/ord.js
parentc34a22b7f932ef8038641a76a756e1cdf6f0f296 (diff)
downloadmongo-aff08f0357b29a7ab03bd7d548c8c677ad0432c7.tar.gz
SERVER-49385 Make SBE fail cleanly when required index is dropped while yielded
Diffstat (limited to 'jstests/core/ord.js')
-rw-r--r--jstests/core/ord.js45
1 files changed, 19 insertions, 26 deletions
diff --git a/jstests/core/ord.js b/jstests/core/ord.js
index 4a76f831246..9273d7034f9 100644
--- a/jstests/core/ord.js
+++ b/jstests/core/ord.js
@@ -1,56 +1,49 @@
-// check that we don't crash if an index used by an earlier or clause is dropped
-// @tags: [
-// sbe_incompatible,
-// ]
-
-// Dropping an index kills all cursors on the indexed namespace, not just those
-// cursors using the dropped index. This test is to serve as a reminder that
-// the $or implementation may need minor adjustments (memory ownership) if this
-// behavior is changed.
-
+// Test the dropping indexes required by an indexed $or causes the query to fail cleanly.
+//
+// @tags: [requires_getmore]
(function() {
"use strict";
load("jstests/libs/fixture_helpers.js"); // For FixtureHelpers.
-const t = db.jstests_ord;
-t.drop();
+const coll = db.jstests_ord;
+coll.drop();
-t.createIndex({a: 1});
-t.createIndex({b: 1});
+assert.commandWorked(coll.createIndex({a: 1}));
+assert.commandWorked(coll.createIndex({b: 1}));
for (let i = 0; i < 80; ++i) {
- t.save({a: 1});
+ assert.commandWorked(coll.insert({a: 1}));
}
for (let i = 0; i < 100; ++i) {
- t.save({b: 1});
+ assert.commandWorked(coll.insert({b: 1}));
}
-const c = t.find({$or: [{a: 1}, {b: 1}]}).batchSize(100);
+const cursor = coll.find({$or: [{a: 1}, {b: 1}]}).batchSize(100);
for (let i = 0; i < 100; ++i) {
- c.next();
+ cursor.next();
}
-// At this point, our initial query has ended and there is a client cursor waiting
-// to read additional documents from index {b:1}. Deduping is performed against
-// the index key {a:1}.
-t.dropIndex({a: 1});
+// At this point, our initial query has ended and there is a cursor waiting to read additional
+// documents from index {b:1}. In between getMores, drop the indexes depended on by the query. The
+// query should fail when the next getMore executes.
+assert.commandWorked(coll.dropIndex({a: 1}));
+assert.commandWorked(coll.dropIndex({b: 1}));
-// Dropping an index kills all cursors on the indexed namespace, not just those
-// cursors using the dropped index.
if (FixtureHelpers.isMongos(db)) {
// mongos may have some data left from a previous batch stored in memory, so it might not
// return an error immediately, but it should eventually.
assert.soon(function() {
try {
- c.next();
+ cursor.next();
return false; // We didn't throw an error yet.
} catch (e) {
return true;
}
});
} else {
- assert.throws(() => c.next());
+ const error = assert.throws(() => cursor.next());
+ assert.commandFailedWithCode(error, ErrorCodes.QueryPlanKilled);
}
})();