Repository navigation
fix: [OCISDEV-1360] Cache LDAP instance mapper lookups - #12823
Merged
Merged
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
2403905
force-pushed
the
fix/OCISDEV-1360
branch
from
August 19, 2026 21:20
ef8eb9e to
7a8e4ee
Compare
mzner
approved these changes
Aug 20, 2026
jvillafanez
approved these changes
Aug 20, 2026
| ttlcache.WithTTL[string, string](time.Duration(config.InstanceMapperCacheTTL)), | ||
| ttlcache.WithDisableTouchOnHit[string, string](), | ||
| ) | ||
| go instanceCache.Start() |
Member
There was a problem hiding this comment.
We should call Stop at some point, to avoid leaving dangling goroutines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue:
Uncached N+1 LDAP lookup during user listing in the graph service's LDAP identity backend, triggered by the multi-tenant/instance-mapper configuration.
Call chain
GET /graph/v1.0/users→Graph.GetUsers(services/graph/pkg/service/v0/users.go:316) →LDAP.GetUsers→LDAP.FilterUsers(services/graph/pkg/identity/ldap.go:761/766) — one LDAP search returns the whole page of users.usersFromLDAPEntries(ldap.go:823) loops over every returned user and callscreateUserModelFromLDAPper entry.instanceURLTemplate/crossInstanceReferenceTemplateare configured,createUserModelFromLDAP(ldap.go:1061-1122) loops over each user's instance/guest attribute values and, for each one, callsgetInstanceName→getInstance(ldap.go:1602/1616), which fires a brand-new LDAPSearchto resolve the tenant/instance name.getInstancehas no cache — every call goes straight to LDAP (unlike other identity lookups inservices/graph/pkg/identity/cache.go, which are cached).itemnotfound— but still cost a full LDAP round-trip.Net effect: a single
GET /graph/v1.0/userscall turns into N (users per page) × M (instance attrs per user) synchronous, uncached LDAP round-trips. Under 100 concurrent VUs this saturates the LDAP connection pool.Bugfix: Cache LDAP instance mapper lookups
In multi-instance deployments, resolving a user's instance name/ID during
GET /graph/v1.0/users(and group member expansion) issued a fresh, uncachedLDAP search per instance/guest attribute value on every request. Under load
this multiplied into large numbers of redundant LDAP round-trips per page of
users, saturating the LDAP connection pool and causing request timeouts. The
LDAP identity backend now caches instance mapper lookups, including negative
(not-found) results, for a configurable TTL
(
OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL, default 60s).Related:
#12897
#12898
#12899