[SERVER-11836] $or with "special" query fails sometimes in 2.4, not in 2.5 Created: 22/Nov/13  Updated: 10/Dec/14  Resolved: 23/Nov/13

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.4.9
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Luke Lovett Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: 26qa, nqf
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> db.serverBuildInfo()
{
"version" : "2.4.9-pre-",
"gitVersion" : "38b3b8f7395d6717efd570a62dc1c2c085d1b049",
"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -fno-builtin-memcmp -O3",
"allocator" : "tcmalloc",
"versionArray" : [
2,
4,
9,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}
and
> db.serverBuildInfo()
{
"version" : "2.5.5-pre-",
"gitVersion" : "4d722953fa6e7f0cd8732601ed7c5c1cb8808bad",
"OpenSSLVersion" : "",
"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -Wl,-z,now -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp",
"allocator" : "tcmalloc",
"versionArray" : [
2,
5,
5,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}


Issue Links:
Related
is related to SERVER-3984 Support $or and geo queries Closed
Operating System: ALL
Steps To Reproduce:

2.5.5-pre-

> db.c.insert({loc:{type:"Point",coordinates:[0,0]}})
Insert WriteResult({ "ok" : 1, "n" : 1 })
> db.c.ensureIndex({loc:"2dsphere"})
> db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]})
{ "_id" : ObjectId("528fcfc56ce2fec2710a1365"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
> db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1})
{ "_id" : ObjectId("528fcfc56ce2fec2710a1365"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
> db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}).count()
1

2.4.9-pre-

> db.c.insert({loc:{type:"Point",coordinates:[0,0]}})
> db.c.ensureIndex({loc:"2dsphere"})
> db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]})
error: { "$err" : "$or may not contain 'special' query", "code" : 13291 }
> db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1})
{ "_id" : ObjectId("528fcfc55142cd7d1e23d1c5"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
> db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}).count()
Fri Nov 22 13:44:19.839 count failed: {
	"errmsg" : "exception: $or may not contain 'special' query",
	"code" : 13291,
	"ok" : 0
} at src/mongo/shell/query.js:180

Participants:

 Description   

Queries with the $or operator throw an error in the latest nightly for 2.4 when used with an array that contains any geospatial operator (described in error message as a "special" query). Version 2.5 does not throw this error.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 23/Nov/13 ]

This is an improvement for 2.6 that cannot go in 2.4

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