Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
921 stars 166 forks source link

Error message from mongoDB when addUsersToRoles #254

Closed nk31 closed 6 years ago

nk31 commented 6 years ago

In my business simulation game I have a mongoDB collection where each document represents a 'game group'. I use the _id of a 'game group' with the prefix '__' (because numbers are not allowed at the beginning of a group name) to add users to such a group via

Roles.addUsersToRoles(user, role, group);

See an example of a user and his groups and roles in the group in the screenshot: bildschirmfoto 2017-10-22 um 18 22 17

But this works in my case just fo 25 array entries. If I want to add the shown user e.g. to another group, I got the error

errmsg: 'WiredTigerIndex::insert: key too large to index, failing 1051 '

from mongoDB. It seems that adding users to groups is limited because the mongoDB index on the roles field doesn't support more entries. I tried this with shorter group names like 'group1', 'group2' and so on and was able to insert 35 entries. But a limit is also there.

Maybe there is a connection to the issue #246 ?

In an post a similar error in context to mongoDB and a workaround with mongod --setParameter failIndexKeyTooLong=false is mentioned but not recommended.

I am using Meteor 1.5.2.2, alanning roles 1.2.16 and mongo 3.2.15

Do I something wrong? Is there a solution?

nk31 commented 6 years ago

I found the mistake ... it was my fault. Inadvertently I have set an string index for the role field in the schema of the user collection. Problem solved.