-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Query Execution
-
Fully Compatible
-
ALL
-
-
Query Execution 2021-04-19, Query Execution 2021-05-03
Around line 829 of "src/mongo/db/query/sbe_stage_builder.cpp", there is an invariant at the top of the buildSort() method.
Here is a valid plan that can cause this invariant() to fail:
> db.coll.createIndex({y: 1, x: 1})
> db.coll.find({y: {$gt: 0}, x: {$gte: 20}}, {_id: 0, y: 1, x: 1}).sort({x:-1}).limit(2)
The "limit(2)" in the query above forces the QueryPlanner to generate a PROJECTION_COVERED / SORT / IXSCAN plan, where the input to sort stage is coming directly from the index keys.