[SERVER-7964] Server at 100% CPU, slow queries (15s) in spite of indexes Created: 17/Dec/12  Updated: 17/Dec/12  Resolved: 17/Dec/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.0.1, 2.2.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Sebastian Goodman Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 10.10 Server, Dual Core 2.7Ghz Xeon, 8GB RAM


Operating System: ALL
Participants:

 Description   

Every 2 days, our primary instance hits 100% CPU usage and has to be restarted. By setting the profiling level to 1, I discovered that there are about a dozen EXTREMELY slow count() queries being completed per second:

> db.system.profile.find()
{ "ts" : ISODate("2012-12-16T20:31:39.078Z"), "op" : "command", "ns" : "stylesaint.$cmd", "command" : { "count" : "tears", "query" : { "_id" :

{ "$gt" : ObjectId("50cdeadeaf58d3de96000294") }

, "active" : true, "is_image_processed" : true, "hidden_from_feed" : false, "hidden_from_public_feeds" : false }, "fields" : null }, "ntoreturn" : 1, "responseLength" : 48, "millis" : 13930, "client" : "wouldntyouliketoknow" }
... other similar results, only the ObjectId is different

I've run explain() on a number of these queries. Mongo seems to intelligently choose the index that gives it the fewest number of scanned documents, which is cool. But it means that one explain() does not explain them all. Here's an example:

> db.tears.find({ "_id" :

{ "$gt" : ObjectId("50cdeadeaf58d3de96000294") }

, "active" : true, "is_image_processed" : true, "hidden_from_feed" : false, "hidden_from_public_feeds" : false }).explain()
{
"cursor" : "BtreeCursor id",
"isMultiKey" : false,
"n" : 4,
"nscannedObjects" : 5,
"nscanned" : 5,
"nscannedObjectsAllPlans" : 23,
"nscannedAllPlans" : 25,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" :

{ "_id" : [ [ ObjectId("50cdeadeaf58d3de96000294"), ObjectId("ffffffffffffffffffffffff") ] ] }

,
"server" : "ip-10-169-65-66:27017"
}

I have not found any queries yet where nscanned is more than a few hundred documents.

This particular collection has less than half a million documents. Whether or not these slow queries are related to the server failure, I'd like to speed them up. But my main issue is the server failure.

I created a topic with the Google group. We can take the discussion there if you prefer: https://groups.google.com/forum/#!topic/mongodb-user/NbiWPSeYg28



 Comments   
Comment by Ian Whalen (Inactive) [ 17/Dec/12 ]

Hi Sebastian, the Google Groups forums are definitely the best place to begin this conversation - I'm going to close this for now and allow someone from our team to follow up at the link you provided. If it turns out you've identified a bug then please do reopen this ticket.

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