[SERVER-10709] Invalid BSON docs lead to errors in complex queries Created: 08/Sep/13  Updated: 10/Dec/14  Resolved: 09/Sep/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.4.5, 2.4.6
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Fabrizio Moscon Assignee: Stennie Steneker (Inactive)
Resolution: Duplicate Votes: 0
Labels: bson, query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux ubuntu 12.10


Attachments: File users5.bson    
Issue Links:
Duplicate
duplicates SERVER-9639 2dsphere indexes with {2dsphereIndexV... Closed
Operating System: Linux
Steps To Reproduce:

load this dump: http://privatepaste.com/download/576b7e1184

run the index: db.users5.ensureIndex(

{ "_id": 1, "times.current_location": 1, "places.current.geolocation" : "2dsphere"}

,

{ "sparse": true }

);

run this command
db.runCommand( { "geoNear": "users5", "near":

{ "type": "Point", "coordinates": [ 0,0 ] }

, "spherical" : true } )

Participants:

 Description   

I believe there are few documents stored in my db which are not BSON valid or cause issue when retured, since when they are included into the result set of $and $or $geonear queries they made it error. I have identified one record which is definitely causing this problem. The only thing I can see is when I print it on the shell it indents wrongly and misses some key, but when it is exported it is a valid JSON and the dump also looks a correct binary.

db.runCommand( { "geoNear": 'users5', "near":

{ "type": "Point", "coordinates": [ 0, 0 ] }

, "spherical": true, num: 1 } )
{
"ns" : "your_db.users5",
"results" : [ ],
"errmsg" : "exception: wrong type for field () 10 != 2",
"code" : 13111,
"ok" : 0
}

Further details on http://pastie.org/8308587



 Comments   
Comment by Stennie Steneker (Inactive) [ 09/Sep/13 ]

Hi Fabrizio,

The issue is that 2dsphere indexes in 2.4.6 do not honour the sparse option and are not sparse by default. See SERVER-9639, which has been fixed in the 2.5 development branch. The BSON error is that the $geonear command is expecting a string (type 2) and instead finding a null (type 10): http://bsonspec.org/#/specification.

I tested your sample data with MongoDB 2.5.2 (unstable/development release) and the $geoNear works as expected (note: you do not have to specify sparse).

I'm resolving this as a duplicate of SERVER-9639. This fix is currently not tagged for a backport to 2.4 but I've asked for a review if backport is possible.

Regards,
Stephen

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