Uh oh!
There was an error while loading. Please reload this page.
feat: locally cache frequently requested LDAP mapping data - #54429
Conversation
29d5976 to
4e03364Compare
come-nc
left a comment
There was a problem hiding this comment.
I tend to be a bit scared about this kind of things, we cache stuff from LDAP to DB to avoid too many LDAP queries, and then we cache stuff from DB to Cache to avoid DB queries.
Why local cache and not distributed? Is it because the cache is local that there is the FIXME about broadcasting?
Why the limit to 2000 by default, what is the risk of putting too much lines in Cache? 1MiB does not sound like that much.
| /** @var array caches Names (value) by DN (key) */ | ||
| protected $cache = []; | ||
| protected function initLocalCache(): void { | ||
| if ($this->isCLI || !$this->cacheFactory->isLocalCacheAvailable()) { |
There was a problem hiding this comment.
For APCu does not have a shared cache. There is no benefit over the runtime cache that was already present.
| return; | ||
| } | ||
| $section = \str_contains($this->getTableName(), 'user') ? 'u/' : 'g/'; |
There was a problem hiding this comment.
| $section = \str_contains($this->getTableName(), 'user') ? 'u/' : 'g/'; | |
| $section = $this->getTableName(); |
Why make it more complicated than this?
There was a problem hiding this comment.
Why make it more complicated than this?
It is shorter and thus may save allocation of bytes in APCU.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It showed that 5% of our queries are just those lookups. UPDATE looking at current data it is 7% of all queries that are
Local cache is faster, and does not require any networking. There is also no global state here, but data that barely changes (and for that we have logic already).
When APCu overflows, then the entire cache is flushed, which then is quite expensive across the whole instance. |
4e03364 to
7d99e6eCompareblizzz
commented
Oct 15, 2025
/backport to stable32 |
7d99e6e to
8fc543bCompare
This comment was marked as resolved.
This comment was marked as resolved.
8fc543b to
d91ce32Compare
artonge
left a comment
There was a problem hiding this comment.
Looks good to me besides nitpick
Does it mean that admin would need to flush the cache if they change one user's display name? If so, we'll need to update the documentation.
| return; | ||
| } | ||
| $useLocalCache = $this->config->getValueString('user_ldap', 'use_local_mapping_cache', 'auto', false); |
There was a problem hiding this comment.
From a first glance, I suppose Lexicon support would be a follow-PR as we have other switches as well.
blizzz
commented
Oct 16, 2025
No, this is unrelated to the display name. It only stores DNs to a userid, or false if there is none (e.g. local users are thrown against this through the user abstraction layer on userExists calls). |
This comment was marked as resolved.
This comment was marked as resolved.
b3483f0 to
81e7d06Compare
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- has the advantage that queries will be reported in the query.log when configured Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
81e7d06 to
49f1c3fCompareblizzz
commented
Oct 17, 2025
|
Uh oh!
There was an error while loading. Please reload this page.

Summary
We save that looking up DN by user/group ID is taking up to 5% of all database queries. Albeit they are simple and do not transfer much data, it is still worthwhile to reduce them, since this data barely ever changes.
Checklist