Repository navigation
fix: [OCISDEV-1360] Cache LDAP instance mapper lookups - #12899
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
enabled auto-merge (squash)
September 8, 2026 07:14
mklos-kw
approved these changes
Sep 8, 2026
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 calls createUserModelFromLDAP per entry.
Because instanceURLTemplate/crossInstanceReferenceTemplate are configured, createUserModelFromLDAP (ldap.go:1061-1122) loops over each user's instance/guest attribute values and, for each one, calls getInstanceName → getInstance (ldap.go:1602/1616), which fires a brand-new LDAP Search to resolve the tenant/instance name.
getInstance has no cache — every call goes straight to LDAP (unlike other identity lookups in services/graph/pkg/identity/cache.go, which are cached).
Several referenced instance/member DNs don't resolve (stale data, recur every ~1s), so those lookups fail with itemnotfound — but still cost a full LDAP round-trip.
Net effect: a single GET /graph/v1.0/users call 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, uncached
LDAP 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).