-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expensive reindex when local roles are deleted #140
Comments
It is slightly more complicated than I first understood. There is actually only one reindex call (and it's for the portal root), because the recursive calls to itself set reindex=0. However, reindexing on the portal root is still a very expensive process since reindexObjectSecurity is itself recursive. We still don't need to do call this in a lot of cases. I think something like this may work, with my changes noted in comments
|
Be very careful! Local roles affect not only the object where they are assigned but also all descendants. This implies that deleting a local role may require In the use case of user deletion, the inconsistency will not have an immediate effect. But if a user should in the future be created with the same id (as the one deleted), then his searches may find objects he cannot access. For the reason above, I am against calling Should your application require something like this, I suggest to implement your own |
But shouldn't that be accounted for in my proposal? It would run a reindex on any object that has local roles and all of its descendants. This is due to reindexObjectSecurity always being recursive - if you call only portal.reindexObjectSecurity() it will actually update the security indexes of brain in the catalog. |
Eric Wohnlich wrote at 2024-6-18 08:34 -0700:
But shouldn't that be accounted for in my proposal? It would run a reindex on any object that has local roles _and all of its descendants_. This is due to reindexObjectSecurity always being recursive - if you call portal.reindexObjectSecurity it will actually update the security indexes of everything in the catalog.
Maybe. Your proposal so far has not yet been precise.
When I remember right, then `reindexObjectSecurity` is itself
recursive. If we call it on `obj` (after all local roles
on `obj` and its descendants have been updated) we do not need to
to call it on descendants.
This suggests the following approach:
* perform a full tree traversal to update local roles on all objects
and report if any local role setting has been updated
* perform a `reindexObjectSecurity` on the root object if local role
setting have been changed.
If a user has created a content object, then he will be listed
in its "Owner" local role setting.
Thus, the approach will still `reindexObjectSecurity` on many
unnecessary objects.
We can refine the approach by passing a `reindex_required`
down into the tree traversal.
`reindex_required` is set at an object, if local roles
have to be updated at the object.
When we go up, we call `reindexObjectSecurity` when
the local `reindex_required` is True and the passed in
`reindex_required` has been false -- this is a top level object
where lcal role changes may affect the object and its descendants.
|
https://github.com/zopefoundation/Products.CMFCore/blob/master/src/Products/CMFCore/MembershipTool.py#L457 This method handles local role removal in a variety of cases but I am probably interested in the process of deleting a user. CMFPlone.controlpanel.browser.usergroups_usersoverview calls this method with recursive=True. So what appears to be happening is that the entire site is traversed when a user is deleted and each of those objects calls reindexObjectSecurity. This happens even if the user has no local roles.
What I did:
Deleted a user with no local roles
What I expect to happen:
Receiver a response in a reasonable amount of time.
What actually happened:
Response took a VERY long time to be received.
What version of Python and Zope/Addons I am using:
None
Proposal
The text was updated successfully, but these errors were encountered: