[DOCS-14394] Investigate changes in SERVER-51072: $skip and $limit stages silently round large doubles to MAX_LONG Created: 30/Apr/21  Updated: 13/Nov/23  Resolved: 31/Aug/21

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 5.0.0-rc0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Ian Fogelman
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-51072 $skip and $limit stages silently roun... Closed
Participants:
Days since reply: 2 years, 23 weeks, 1 day ago
Epic Link: DOCSP-15042
Story Points: 3

 Description   

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.)



 Comments   
Comment by Githook User [ 31/Aug/21 ]

Author:

{'name': 'ian fogelman', 'email': 'ian.fogelman@mongodb.com', 'username': 'ianf-mongodb'}

Message: DOCS-14394 Add 64-bit integer limit notes to and pages
Branch: v5.0
https://github.com/mongodb/docs/commit/a06be75f86b97df4824db50ab6702e57dceb106c

Comment by Githook User [ 31/Aug/21 ]

Author:

{'name': 'ian fogelman', 'email': 'ian.fogelman@mongodb.com', 'username': 'ianf-mongodb'}

Message: DOCS-14394 Add 64-bit integer limit notes to and pages
Branch: master
https://github.com/mongodb/docs/commit/f8b15986988b40b4cebb137793fd7adebefc026b

Generated at Thu Feb 08 08:10:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.