[SERVER-13520] The $exists operator fails if the field is not indexed when using --notablescan Created: 09/Apr/14  Updated: 10/Dec/14  Resolved: 09/Apr/14

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

Type: Bug Priority: Major - P3
Reporter: Tom Robinson Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test.js    
Issue Links:
Related
related to DOCS-3098 collection scan for $exists is no lon... Closed
Backwards Compatibility: Major Change
Operating System: ALL
Steps To Reproduce:

Start mongod without --notablescan and run the attached script, the output is below:

MongoDB shell version: 2.6.0
connecting to: test
{ "_id" : ObjectId("53453ea01a5e1a8ac3c64a8d"), "a" : 1 }
{ "_id" : ObjectId("53453ea01a5e1a8ac3c64a8e"), "a" : 2 }
{ "_id" : ObjectId("53453ea01a5e1a8ac3c64a8f"), "a" : 3 }
{ "_id" : ObjectId("53453ea01a5e1a8ac3c64a90"), "b" : 1 }
{ "_id" : ObjectId("53453ea01a5e1a8ac3c64a91"), "b" : 2 }
{ "_id" : ObjectId("53453ea01a5e1a8ac3c64a92"), "b" : 3 }

Start mongod with --notablescan and run the attached script, the output is below:

MongoDB shell version: 2.6.0
connecting to: test
{ "_id" : ObjectId("53453eb5677ff00bb2c52786"), "a" : 1 }
{ "_id" : ObjectId("53453eb5677ff00bb2c52787"), "a" : 2 }
{ "_id" : ObjectId("53453eb5677ff00bb2c52788"), "a" : 3 }
2014-04-09T13:36:05.429+0100 error: {
        "$err" : "Unable to execute query: error processing query: ns=test.exist
swithoutindex limit=0 skip=0\nTree: b exists\nSort: {}\nProj: {}\n No query solu
tions",
        "code" : 17007
} at src/mongo/shell/query.js:131

Participants:

 Description   

The $exists operator fails if the field that is being checked for existence is not indexed and --notablescan is set. This is logical but is different to the behaviour in 2.4.9. The error message doesn't mention that it's due to table scans being disabled.

I noticed this after upgrading from 2.4.9 to 2.6.0.



 Comments   
Comment by David Storch [ 09/Apr/14 ]

Opened DOCS-3098.

Comment by David Storch [ 09/Apr/14 ]

Hi Tom,

As you suspect, the "no query solutions" error message happens because 1) there are no indexed solutions available for the $exists query, and 2) collection scans are disallowed by the notablescan option. Therefore, I'm resolving this issue as "Works as Designed, Backwards Breaking". Thanks for pointing out the behavior change between 2.4 versions and 2.6.0--I'm going to make sure that this gets properly documented by our docs team. Do let us know if you find anything else surprising about 2.6.0!

Thanks,
Dave

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