spring-projects / spring-projects/spring-security

SEC-3131: JdbcMutableAclService can be very slow to update ACLs with many children, grandchildren etc

Open
#3,330 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

in: acl type: bug type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Simon van der Sluis (Migrated from SEC-3131) said:

The JdbcMutableAclService method public MutableAcl updateAcl(MutableAcl acl)
calls clearCacheIncludingChildren(ObjectIdentity objectIdentity), which recursively works it's way through all of an ObjectIdentities children and their children etc.

We have a very hierarchical structure controlled by ACLS, when this structure gets large, and we update the ACLs of the root object, this recursion is a killer, as each call to clearCacheIncludingChildren(.) involves a DB query.

I have worked around this problem by implementing my own JdbcMutableAclService which instead of recursively clearing the ObjectIdentities simply calls aclCache.clearCache(). (Hooray for dependency injection.)

Performance improved from ~3 seconds to sub second on a smallish data set.

I'm not sure if the hammer approach to clearing the cache is suitable for all situations, but the current recursive approach isn't either.

Perhaps JdbcMutableAclService should support different strategies for controlling the cache.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JdbcMutableAclService.updateAcl(MutableAcl) and trace its call to clearCacheIncludingChildren(ObjectIdentity), then compare that recursive path with the reported aclCache.clearCache() workaround. Done means defining a cache-clearing strategy that avoids excessive database queries for deeply nested ACLs without losing cache correctness.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.