[SERVER-7110] _addSpecial() flags not used by DBCollection.getCount() method eg collection.find()._addSpecial().count() Created: 22/Sep/12  Updated: 14/Mar/17  Resolved: 24/Sep/12

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

Type: Bug Priority: Blocker - P1
Reporter: Joe Davis Assignee: Aaron Staple
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux CentOS/RHEL, Mac OSX


Attachments: Text File mongo-session.txt    
Issue Links:
Documented
is documented by DOCS-9028 _addSpecial() flags not used by DBCol... Closed
Operating System: ALL
Participants:

 Description   

We tag each query for profiling using _addSpecial and $comment:

db.test.find(

{field:"value"}

)._addSpecial("$comment", "[COMMENT]")

These show up correctly in the logs and db.currentOp() when using collection.find() method.

But any flags added via _addSpecial are not used by the collection's getCount() method. We use the count method to display a query's total count:

db.test.find(

{field:"value"}

).count()
db.test.find(

{field:"value"}

)._addSpecial("$comment", "[COMMENT]").count()

The .count() disregards any special flags, so profiling/tracing/db.currentOp() do not show our unique tag for that query.

Based on the source code, the DBCollection.getCount() method does not accept any special flags parameters, so it looks like a core server issue.

See attached console session, where a .find()._addSpecial shows the $comment via db.currentOp(), but it is not displayed when I issue a .find()._addSpecial().count()



 Comments   
Comment by Joe Davis [ 24/Sep/12 ]

Awesome, works great.

Feel free to close this as not an issue...

Comment by Aaron Staple [ 24/Sep/12 ]

Hi Joe,

It looks like the 'special' version of $comment isn't supported with count. One thing you might do is just put $comment inside your query like an operator, which is also supported:

db.test.find( { msg:"Test message 10000", $comment:"a comment" } );

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