Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-14394

Investigate changes in SERVER-51072: $skip and $limit stages silently round large doubles to MAX_LONG

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0.0-rc0
    • Component/s: manual, Server
    • Labels:
      None

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ian.fogelman Ian Fogelman
              Reporter:
              backlog-server-pm Backlog - Core Eng Program Management Team
              Participants:
              Last commenter:
              Ian Fogelman Ian Fogelman
              External Reviewer:
              Nikita Lapkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since reply:
                2 weeks, 2 days ago
                Date of 1st Reply: