-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
Fully Compatible
-
ALL
-
200
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Root Cause
The failing assertion is in jstests/noPassthrough/query/joins/join_optimization_server_status.js:
assert.docEq({}, fallbackReasonDelta(before, after), "query was fully optimized", attr);
The joinOptimization serverStatus metrics (including fallbackReasons) are cumulative counters for the whole mongod process, not scoped to the test's own query. FTDC periodically issues its own internal aggregate commands (e.g. a $collStats pipeline) against the server. Those pipelines never contain a $lookup, so they pass through AggJoinModel::pipelineEligibleForJoinReordering() and increment the shared fallbackReasons.noLookup counter, just like any other non-join pipeline would.
When an FTDC collection cycle happens to fire in the narrow window between the test's "before" and "after" serverStatus() snapshots, it increments noLookup by 1 even though the test's own $lookup pipeline was fully optimized. This causes the assert.docEq({}, ...) check to intermittently fail with:
expected document { } and actual document { "noLookup" : 1 } are not equal : query was fully optimized
This is a test-isolation issue, not a join optimizer bug: every per-query counter/histogram for the test's actual pipeline (joinOptimizationConsidered, joinOptimizedTrue, numEnumerations, and all histogram deltas) matched exactly in the failing run, confirming the query itself was optimized correctly.