grails-spring-security-acl icon indicating copy to clipboard operation
grails-spring-security-acl copied to clipboard

AclObjectIdentityGormService::findAllByParentObjectIdAndParentAclClassName() performance issue

Open vdusa opened this issue 5 years ago • 0 comments

Method AclObjectIdentityGormService::findAllByParentObjectIdAndParentAclClassName() searches now AclObjectIdentity objects so, that ALL objects of AclObjectIdentity are retrieved, and then the result is searched in this list (see below):

    @CompileDynamic
    @ReadOnly
    List<AclObjectIdentity> findAllByParentObjectIdAndParentAclClassName(Long objectId, String aclClassName) {
        //findQueryByParentObjectIdAndParentAclClassName(objectId, aclClassName).list()
        List<AclObjectIdentity> aclObjectIdentityList = findAll()
        aclObjectIdentityList.findAll { AclObjectIdentity oid ->
            (oid?.parent?.aclClass?.className == aclClassName) &&  ( oid?.parent?.objectId == objectId)
        }
    }

This method calls AclObjectIdentityGormService::findAll(), which retrieves all AclObjectIdentity objects. Since we have about 30'000 AclObjectIdentity objects (this amount still increases), then all these objects are in hibernate session, which causes performance problems.

As a workaround, we have created our own bean inherited from AclObjectIdentityGormService, where findAllByParentObjectIdAndParentAclClassName() is overloaded and uses findQueryByParentObjectIdAndParentAclClassName() as it was earlier in the plugin before the commit 4d53a88 from 1. Dec 2017 by @sdelamo has been made.

We don't know, what was the reason of using findAll() here, but we think that such approach is algorithmically unhappy. Could you help us to solve this problem correctly, please?

vdusa avatar Jul 30 '19 14:07 vdusa