summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/plan_cache_list_plans_new_format.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/plan_cache_list_plans_new_format.js')
-rw-r--r--jstests/noPassthrough/plan_cache_list_plans_new_format.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/noPassthrough/plan_cache_list_plans_new_format.js b/jstests/noPassthrough/plan_cache_list_plans_new_format.js
index f8f96d56cbf..cd0a7fb0320 100644
--- a/jstests/noPassthrough/plan_cache_list_plans_new_format.js
+++ b/jstests/noPassthrough/plan_cache_list_plans_new_format.js
@@ -55,5 +55,33 @@
assert.eq(cachedStage, winningExecStage, `Information about the winning plan in "cachedPlan" is
inconsistent with the first element in "creationExecStats".`);
+ // Ensures that the new format preservers information about the failed plans.
+ assert(coll.drop());
+
+ // Setup the database such that it will generate a failing plan and a succeeding plan.
+ const numDocs = 32;
+ const smallNumber = 10;
+ assert.commandWorked(
+ testDB.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: smallNumber}));
+ for (let i = 0; i < numDocs * 2; ++i)
+ assert.commandWorked(coll.insert({a: ((i >= (numDocs * 2) - smallNumber) ? 1 : 0), d: i}));
+
+ // Create the indexes to create competing plans.
+ assert.commandWorked(coll.createIndex({a: 1}));
+ assert.commandWorked(coll.createIndex({d: 1}));
+
+ // Assert that the find command found documents.
+ key = {query: {a: 1}, sort: {d: 1}, projection: {}};
+ assert.eq(smallNumber, coll.find(key.query).sort(key.sort).itcount());
+ res = assert.commandWorked(coll.runCommand('planCacheListPlans', key));
+
+ // There should have been two plans generated.
+ assert.eq(res["creationExecStats"].length, 2);
+
+ // The second plan should have failed.
+ assert(res["creationExecStats"][1].failed);
+
+ // The failing plan should have a score of 0.
+ assert.eq(res["candidatePlanScores"][1], 0);
MongoRunner.stopMongod(conn);
})();