[SERVER-19474] Calling createIndex() can cause the shell to stall Created: 17/Jul/15  Updated: 11/Sep/17  Resolved: 22/Jul/15

Status: Closed
Project: Core Server
Component/s: Shell, Testing Infrastructure
Affects Version/s: 3.1.5
Fix Version/s: 3.1.7

Type: Bug Priority: Minor - P4
Reporter: J Delaney Assignee: J Delaney
Resolution: Done Votes: 0
Labels: dnsf
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-31038 DBCollection.prototype.createIndexes ... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

From the shell run:

db.foo.ensureIndex({a: 1}, {length: 1.7976931348623157e+308})

Participants:

 Description   

When createIndex is called in the shell it checks if the options provided are an array with if ( options.length ). If options is an object with a a field called length that is very large the shell will stall. This can be fixed by check if it's an array with if ( Array.isArray(options ). This can cause problems in jstestfuzz.



 Comments   
Comment by Githook User [ 28/Jul/15 ]

Author:

{u'username': u'j-delaney', u'name': u'J Delaney', u'email': u'j.delaney@mongodb.com'}

Message: SERVER-19474 Improve validation for createIndex array options in shell

Use built-in ES5 function for less error-prone array detection and
limit the number of array elements to 3.
Branch: master
https://github.com/mongodb/mongo/commit/4f6972dd71c747418bbe4e19c3c71f911f1441e0

Comment by J Delaney [ 22/Jul/15 ]

Running

db.foo.createIndex({a: 1}, ["a", "b", "c", true, "d"]);


will no longer create a unique index on a with a name of 'd' but will instead throw an error with message "Index options that are supplied in array form may only specify three values: name, unique, dropDups"

Comment by Githook User [ 22/Jul/15 ]

Author:

{u'username': u'j-delaney', u'name': u'J Delaney', u'email': u'j.delaney@mongodb.com'}

Message: SERVER-19474 Improve validation for createIndex array options in shell

Use built-in ES5 function for less error-prone array detection and
limit the number of array elements to 3.
Branch: master
https://github.com/mongodb/mongo/commit/4f6972dd71c747418bbe4e19c3c71f911f1441e0

Generated at Thu Feb 08 03:51:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.