Mongo DB sort operation gives error "Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit."

Hi, I am having complex hierarchy of document up to 20 levels. And more than 1lakh of document. While I am accessing inner most level of document getting error.

com.mongodb.MongoQueryException: Query failed with error code 96 and error message 'errmsg: “Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.“' on server hydprdmsdb4:27020**

Can any one solve this.

0 votes

2 answers

2215 views

ANSWER



Hi Santosh,

You need to enable logs on MongoDBRepository in order to tackle the culprit query. Add the following lines to the log4j.xml file to trace the queries sent to MongoDB:

<category name="org.nuxeo.ecm.core.storage.mongodb.MongoDBRepository">
  <priority value="TRACE" />
</category>
0 votes



I already debug the query it is as follows:

db.getCollection('default').find({ "ecm:primaryType" :{ "$in" : [ "TemplateRoot" , "DocumentRouteModelsRoot" , "SimpleTask" , "CommentRoot" , "Document" , "RoutingTask" , "ConditionalTask" , "UserInvitation" , "Collections" , "ExpriredSearch" , "RouteNode" , "DocumentRoute" , "StoredRenditionSearch" , "Note" , "Collection" , "AdvancedSearch" , "Domain" , "File" , "ManagementRoot" , "Favorites" , "OrderedFolder" , "TaskRoot" , "TaskDoc" , "UserProfile" , "FollowLifeCycleTransitionTask" , "SavedSearch" , "AdvancedContent" , "PermissionsSearch" , "UserInvitationContainer" , "UserWorkspacesRoot" , "DocumentRouteStep" , "Folder" , "WorkspaceRoot" , "quota_heaviest_containers_cv" , "BasicAuditSearch" , "PublishTask" , "StepFolder" , "Comment" , "DocumentRouteInstancesRoot" , "DefaultSearch" , "AdministrativeStatus" , "SectionRoot" , "HiddenFolder" , "Section" , "AdministrativeStatusContainer" , "ConditionalStepFolder" , "RelationSearch" , "user_open_tasks_cv" , "Tag" , "Workspace"]}},{"ecm:id" : 1 , "ecm:parentId" : 1 , "ecm:name" : 1,"dc:modified" :1,"dc:created" :1, "rend:sourceId" :1}).sort({ "dc:created" : 1})

12/01/2017

What is the context of this query ? Is it a query done by Nuxeo itself as a system/admin tasks ?
12/04/2017


Hi,

You can do, for example for 50MB blocking sort:

> mongo <your-server-and-port>
> use admin
> db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes:50151432})

Regards, VS.

0 votes



Hi, I already done this, this will work up to specific limit. After increasing mongo-db documents size it will again give error.
12/01/2017

Please, check your mongodb parameters after changes and verify about internalQueryExecMaxBlockingSortBytes param.
12/01/2017

Hi, I have checked by setting this parameter it is working fine. But If I will add some more hierarchy then again i have to reset this parameter by increasing value. So this is not permanent solution, becoz increasing internalQueryExecMaxBlockingSortBytes will may cause serious memory issue. Just read mongo-DB document about this parameter and it's side-effect.
12/04/2017