From e01827693a20b79a6d4d61f2ecbaa5a659cb466c Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Tue, 12 Dec 2023 12:43:47 +0100 Subject: [PATCH] Avoid shutdown of Infinispan when using cache Closes #24508 Signed-off-by: Alexander Schwartz --- .../infinispan/remotestore/RemoteCacheSessionsLoader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/RemoteCacheSessionsLoader.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/RemoteCacheSessionsLoader.java index f232186750..b5fda004e7 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/RemoteCacheSessionsLoader.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/remotestore/RemoteCacheSessionsLoader.java @@ -33,6 +33,7 @@ import org.infinispan.client.hotrod.impl.operations.OperationsFactory; import org.infinispan.commons.util.CloseableIterator; import org.infinispan.context.Flag; import org.jboss.logging.Logger; +import org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory; import org.keycloak.connections.infinispan.InfinispanConnectionProvider; import org.keycloak.models.KeycloakSession; import org.keycloak.models.sessions.infinispan.initializer.BaseCacheInitializer; @@ -141,7 +142,11 @@ public class RemoteCacheSessionsLoader implements SessionLoader + // With Infinispan 14.0.21/14.0.19, we've seen deadlocks in tests where this future never completed when shutting down the internal Infinispan. + // Therefore, prevent the shutdown of the internal Infinispan during this step. + decoratedCache.putAll(remoteEntries) + ); log.debugf("Successfully finished loading sessions from cache '%s' . Segment: %d, Count of sessions loaded: %d", cache.getName(), ctx.getSegment(), countLoaded);