Avoid caching user data while external storage is unavailable - #51322
Open
hkwi wants to merge 5 commits into
Open
Avoid caching user data while external storage is unavailable#51322hkwi wants to merge 5 commits into
hkwi wants to merge 5 commits into
Conversation
Keep lazy cached user data uninitialized when the user storage provider is temporarily unavailable so later requests retry the provider. Closes keycloak#51321 Signed-off-by: Hiroaki KAWAI <hiroaki.kawai@gmail.com>
hkwi
force-pushed
the
fix-51321-unavailable-lazy-user-cache
branch
from
August 3, 2026 08:42
31832fb to
dfed839
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/storage/UserStorageFailureTest.java:436
groupNameand the realm group are created before thetry, so a failure in either setup transaction or the cache assertion leaves this static provider state and group behind, potentially cascading into later tests. Start thetrybefore setup so the existing cleanup always runs.
FailableHardcodedStorageProvider.groupName = groupName;
Signed-off-by: Hiroaki KAWAI <hiroaki.kawai@gmail.com>
hkwi
force-pushed
the
fix-51321-unavailable-lazy-user-cache
branch
from
August 4, 2026 03:10
a0e7f20 to
dc732a0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/DefaultLazyLoader.java:45
- The new non-cacheable path contradicts the existing
DefaultLazyLoader/LazyLoadercontract that source data is fetched only once: a rejected source is fetched again on every subsequentget. Please document the retry behavior and the predicate's semantics in both API Javadocs so callers do not rely on the old guarantee.
public DefaultLazyLoader(Function<S, D> loader, Supplier<D> fallback, Predicate<S> cacheable) {
Signed-off-by: Hiroaki KAWAI <hiroaki.kawai@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/entities/CachedUser.java:84
UserStorageManager.validateUsercan wrap aStorageUnavailableUserModelDelegatein anotherReadOnlyUserModelDelegatefor a managed member of a disabled organization (UserStorageManager.java:126-130). This direct check then treats the source as available and permanently caches its local fallback data; inspect the delegate chain so the unavailable marker survives wrappers.
return !(userModel instanceof StorageUnavailableUserModelDelegate);
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.
Summary
This prevents an empty group result observed during an LDAP or other user-storage outage from remaining cached until explicit user-cache invalidation.
Closes #51321
Testing
./mvnw -pl model/infinispan -am -DskipTests -DskipTestsuite -DskipExamples -DskipProtoLockCheck install./mvnw -pl model/infinispan -Dtest=DefaultLazyLoaderTest test./mvnw -pl testsuite/integration-arquillian/tests/base -am -DskipTests -DskipExamples -DskipProtoLockCheck install./mvnw -f testsuite/integration-arquillian/pom.xml -Dtest=UserStorageFailureTest#testUnavailableStorageDoesNotCacheEmptyGroups install./mvnw spotless:checkAI assistance
I used OpenAI Codex to assist with investigation, implementation, tests, and pull request preparation. I reviewed and understand the submitted changes.