-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:None
Description
Downstream Change Summary
$skip and $limit aggregation stages throw error if their argument does not fit MAX_LONG
Description of Linked Ticket
$skip and $limit stages do not raise any validation errors when numbers larger than MAX_LONG are passed as their arguments. Instead, they truncate arguments to MAX_LONG which could be confusing.
A few examples:
> db.test.explain().aggregate([{$sort: {x: -1}}, {$skip: 18446744073709552000}, {$limit: 6}]) { "stages" : [ { "$cursor" : { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.test", "indexFilterSet" : false, "parsedQuery" : { }, "queryHash" : "CF095775", "planCacheKey" : "CF095775", "winningPlan" : { "stage" : "SORT", "sortPattern" : { "x" : -1 }, "memLimit" : 104857600, "type" : "simple", "inputStage" : { "stage" : "COLLSCAN", "direction" : "forward" } }, "rejectedPlans" : [ ] } } }, { "$skip" : NumberLong("9223372036854775807") }, { "$limit" : NumberLong(6) } ], "serverInfo" : { "host" : "laplab-work-mac.local", "port" : 27017, "version" : "4.4.1", "gitVersion" : "ad91a93a5a31e175f5cbf8c69561e788bbc55ce1" }, "ok" : 1 }
> db.test.explain().aggregate([{$sort: {x: -1}}, {$skip: 6}, {$limit: 18446744073709552000}]) { "stages" : [ { "$cursor" : { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.test", "indexFilterSet" : false, "parsedQuery" : { }, "queryHash" : "CF095775", "planCacheKey" : "CF095775", "winningPlan" : { "stage" : "SORT", "sortPattern" : { "x" : -1 }, "memLimit" : 104857600, "type" : "simple", "inputStage" : { "stage" : "COLLSCAN", "direction" : "forward" } }, "rejectedPlans" : [ ] } } }, { "$skip" : NumberLong(6) }, { "$limit" : NumberLong("9223372036854775807") } ], "serverInfo" : { "host" : "laplab-work-mac.local", "port" : 27017, "version" : "4.4.1", "gitVersion" : "ad91a93a5a31e175f5cbf8c69561e788bbc55ce1" }, "ok" : 1 }
Scope of changes
Update the Behavior sections of $skip and $limit to say that the stage errors if the argument exceeds the value of MAX_LONG.
We should also update the compatibility notes since this might result in previously-working aggregation pipelines now breaking.
Impact to Other Docs
MVP (Work and Date)
Resources (Scope or Design Docs, Invision, etc.)
- documents
-
SERVER-51072 $skip and $limit stages silently round large doubles to MAX_LONG
- Closed