-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When internalEnableDependencyGraphValidation is enabled, the server injects $_internalValidateArrayness stages between pipeline stages after optimization (see optimize.cpp). This disrupts the pipeline in a way that prevents a leading $match from being pushed down to the query layer as an indexed find. The test shred_documents.js relies on this index pushdown to produce a non-missing {$meta: "indexKey"} value, and fails when the validation stages are present.
Chain of Failure
$_internalValidateArrayness stages are injected into the pipeline between user stages. The {$match: {a: 1}} can no longer be converted into an IXSCAN on the {a: 1} index because the injected stages break the contiguous prefix requirement for pushdown. Without an index scan, {$meta: "indexKey"} evaluates to missing {$addFields: {key: missing}} does not create the field (missing values don't create fields) res[0].hasOwnProperty("key") returns false and the assertion fails
Possible Approaches
Option A: Inject $_internalValidateArrayness stages before the match-to-find pushdown optimization, or mark injected stages as transparent to pushdown so that the $match can still be absorbed into the query layer.
Option B: Skip injecting validation stages before a leading $match that is eligible for pushdown (preserving the optimization).
Option C: Make the test itself resilient — e.g. add a hint to force the index scan, or check for indexKey only when the query planner actually chose an IXSCAN. However, this does not fix the general problem that validation stages interfere with pushdown.
- is depended on by
-
SERVER-125083 Introduce a new jstest suite for testing the dependency graph
-
- In Code Review
-