-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Trivial - P5
-
Affects Version/s: None
-
Component/s: Query Execution
-
None
-
Query Execution
-
Fully Compatible
-
QE 2025-10-13, QE 2025-10-27
-
0
-
None
-
None
-
None
-
None
-
None
-
None
-
None
BF-39875 contains a test failure here:
const comment = "from_plan_cache_flag"; coll.aggregate([{$match: {a: 1}}], {comment}).toArray(); let profileObj = getLatestProfilerEntry(testDB, {"command.comment": comment}); assert.eq(!!profileObj.fromPlanCache, false, profileObj); coll.aggregate([{$match: {a: 2}}], {comment}).toArray(); profileObj = getLatestProfilerEntry(testDB, {"command.comment": comment}); assert.eq(!!profileObj.fromPlanCache, true, profileObj); // fails here!
The test asserts that the second run of the query should have been served from the plan cache. This assertion seems to hold most of the time, and I haven't been able to run into the test failure even when repeating the test several hundred times in a row.
However, it is likely that under adverse conditions, a query cannot be added to the query plan cache, e.g. when the cache is under memory pressure or in other transient states.
To make this and other similar tests more robust, the test code should be adjusted to repeat the query in question until it was finally served from the plan cache. This can be achieved by using assert.soon(), with an exit condition that checks if the query was successfully added to the plan cache.