settings: Maintain a cache/index for assignments by role #9363
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In order to be able to improve the speed of listing all assignments for a specific role, we now maintain a cache of all assignments per role.
The cache implementation is mainly copied from reva's sharecache for the jsoncs3 share manager. It is stored in the metadata service.
Related to: #8938
There is still quite a few things left to do here:
ListRoleAssignments
(by user) performance by just disabling the metadata cache.ocis/services/settings/pkg/store/metadata/store.go
Line 168 in 975a8f6
WriteRoleAssignment
orDeleteRoleAssignment
call the cache file for the affected roles needs to be completely rewritten (including the marshalling/unmarshalling from/to JSON). Appart from creating issues with file versions (Metadata storage creates file revision for every upload #9282) this can be quite expensive with increasing numbers of assignements for a specific role. (On my NFS backed test system creating 1000 users with the default user role assignement already became almost unbearable slow after about 500 users, including sporadic failures)On the positive side of things, this improvements for lookup of assignments by roleid are quite visible. The
$filter=(appRoleAssignments/any(m:m/appRoleId eq 'd7beeea8-8ff4-406b-8fb6-ab2dd81e6b11'))&$orderby=displayName&$expand=appRoleAssignments
query is now down to less than a second (from 14s). Same setup as in #9326.