OptimalBits / node_acl

Access control lists for node applications
2.62k stars 369 forks source link

Max mongo document size #268

Open ezefire opened 6 years ago

ezefire commented 6 years ago

Hi, We noticed that the collection 'roles' adds the user id to the document of its rol. But on mongo there is a max size for each document and adding every userId to that same document could cause that document arrives to that max size. The same happens in the collection 'meta' where all user ids are stored under the same document.

timqian commented 5 years ago

Actually met this issue in our production database,

screen shot 2018-12-31 at 12 24 14 pm

There are too many roles, and met MongoError Resulting document after update is larger than 16777216 when we trying to add more roles

timqian commented 5 years ago

A simple temp solution worked for us without changing the code is removing roles in the large meta document. roles in the big document is used to remove all the permissions associated to ONE resource when removing resource. ref1; ref2; So, with this solution, the issue is we will have unnecessary permissions still in db when resource got deleted.