[SERVER-19349] $type results are inconsistent with indexing enable on Infinity, -Infinity, NaN Created: 09/Jul/15  Updated: 19/Sep/15  Resolved: 28/Jul/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: 2.2.7, 2.4.14, 2.6.10, 3.1.5
Fix Version/s: 3.1.7

Type: Bug Priority: Major - P3
Reporter: David Hatch Assignee: David Hatch
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-19348 $mod results are inconsistent with in... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

In the shell:

> db.test.insert({ a: Infinity })
WriteResult({ "nInserted" : 1 })
> db.test.find({ a : { $type : 1 }})
{ "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }
> db.test.ensureIndex({ a : 1})
{
        "createdCollectionAutomatically" : false,
        "numIndexesBefore" : 1,
        "numIndexesAfter" : 2,
        "ok" : 1
}
> db.test.find({ a : { $type : 1 }})
> db.test.dropIndex({ a : 1 })
{ "nIndexesWas" : 2, "ok" : 1 }
> db.test.find({ a : { $type : 1 }})
{ "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }

Participants:

 Description   

Executing a type query with indexing and without can result in different results for Infinity, -Infinity, NaN.

The issue is in src/mongo/db/query/index_bounds_builder.cpp and caused by implementation of BSONElement.appendMin/MaxForType.



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

Author:

{u'username': u'dhatch', u'name': u'David Hatch', u'email': u'david.hatch@mongodb.com'}

Message: SERVER-19349 Fix lint in index_bounds_builder_test.
Branch: master
https://github.com/mongodb/mongo/commit/76c7aa1e6f680e43ee2b2c02d8681b2b58fef6b5

Comment by David Hatch [ 28/Jul/15 ]

Although this corrects behavior, users relying on indexed find alls not finding Infinity/NaN with $type could see changes in their application. Seems unlikely to cause an issue.

Comment by Githook User [ 28/Jul/15 ]

Author:

{u'username': u'dhatch', u'name': u'David Hatch', u'email': u'david.hatch@mongodb.com'}

Message: SERVER-19348, SERVER-19349: Correct index bounds on $type and $mod.
Branch: master
https://github.com/mongodb/mongo/commit/4273fdf07c5af4bd0fd156f5a8a1d8efa56519fb

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