Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Moped::Errors::QueryFailure: The operation: #<Moped::Protocol::Moped::Errors::QueryFailure: The operation: #<Moped::Protocol::Query @length=210 @request_id=88981 @response_to=0 @op_code=2004 @flags=[] @full_collection_name="comments-loadtest.contents" @skip=24800 @limit=100 @selector={"$query"=>{"_type"=>"CommentThread", "course_id"=>"BerkeleyX/ColWri2.2x/1T2014", "context"=>:course}, "$orderby"=>{"pinned"=>-1, "last_activity_at"=>-1}} @fields=nil>failed with error 17144: "Runner error: Overflow sort stage buffered data usage of 33556783 bytes exceeds internal limit of 33554432 bytes"See https://github.com/mongodb/mongo/blob/master/docs/errors.mdfor details about this error.

Hitting the 32MB limit for in-memory sort. Commonly suggested causes were missing indexes. 

Endpoint: 

"https://courses-loadtest.edx.org/api/discussion/v1/threads/?course_id={}&page_size=100" against a course with ~80,000 posts. 

...

"https://courses-loadtest.edx.org/api/discussion/v1/threads/?course_id=BerkeleyX/ColWri2.2x/1T2014&page_size=100&page=249" 

Query:

Code Block
{"$query"=>{"_type"=>"CommentThread", "course_id"=>"BerkeleyX/ColWri2.2x/1T2014", "context"=>:course}, "$orderby"=>{"pinned"=>-1, "last_activity_at"=>-1}}


There exists a query for 




There exists a query for  "_type", "course_id", "pinned" but none for "_type", "course_id", "pinned", "

but none for 

"_type", "course_id", "pinned", last_activity_at"

 Equivalent query in mongo shell:

Code Block
db.contents.find({_type:"CommentThread", course_id:"BerkeleyX/ColWri2.2x/1T2014", context:"course"}).sort({"pinned":-1, "last_activity_at":-1}).explain()

Will also return the memory error. 

Equivalent query in mongo shell:

...

Suggested solution:

Add the index for because the default query for GET Thread_list uses last_activity_at as a filter.

Code Block
db.contents.findensureIndex({"_type:"CommentThread"" : 1, "course_id" :"BerkeleyX/ColWri2.2x/1T2014", context:"course"}).sort({ 1, "context" : 1, "pinned" : -1, "last_activity_at" : -1 }).explain()

 

...

, {"background":true});