Versions Compared

Key

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

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. 

...

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  "_type", "course_id", "pinned" but none for "_type", "course_id", "pinned", "last_activity_at"

 Equivalent query in mongo shell:

...

Will also return the memory error. 

 

Note: Sorting by "asc" can lead to similar errors as that is not indexed specifically.

Anchor
MissingIndex
MissingIndex

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.ensureIndex({"_type" : 1, "course_id" : 1, "context" : 1, "pinned" : -1, "last_activity_at" : -1 }, {"background":true});

 

Production and browser discussion api:

There is a possibility that this may be an issue on production. 

Image Modified