Rework handling of Infinispan exceptions to stabilize the test
Closes #13164
This commit is contained in:
parent
5dcd436fe3
commit
43539cd3c0
1 changed files with 16 additions and 15 deletions
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite.model.session;
|
package org.keycloak.testsuite.model.session;
|
||||||
|
|
||||||
|
import org.infinispan.commons.CacheException;
|
||||||
import org.keycloak.models.AuthenticatedClientSessionModel;
|
import org.keycloak.models.AuthenticatedClientSessionModel;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.Constants;
|
import org.keycloak.models.Constants;
|
||||||
|
@ -214,23 +215,23 @@ public class OfflineSessionPersistenceTest extends KeycloakModelTest {
|
||||||
int oid = index % offlineSessionIds.size();
|
int oid = index % offlineSessionIds.size();
|
||||||
String offlineSessionId = offlineSessionIds.get(oid);
|
String offlineSessionId = offlineSessionIds.get(oid);
|
||||||
int cid = index % clientIds.size();
|
int cid = index % clientIds.size();
|
||||||
String clientSessionId;
|
try {
|
||||||
while (true) {
|
clientSessionIds.computeIfAbsent(offlineSessionId, a -> Collections.synchronizedList(new LinkedList<>())).add(createOfflineClientSession(offlineSessionId, clientIds.get(cid)));
|
||||||
try {
|
} catch (RuntimeException ex) {
|
||||||
clientSessionId = createOfflineClientSession(offlineSessionId, clientIds.get(cid));
|
// invocation can fail when remote cache is stopping, this is actually part of this test:
|
||||||
break;
|
// "ISPN000217: Received exception from node-8, see cause for remote stack trace
|
||||||
} catch (RuntimeException ex) {
|
// IllegalLifecycleStateException: ISPN000324: Cache 'clientSessions' is in 'STOPPING' state and this is an invocation not belonging to an
|
||||||
// invocation can fail when remote cache is stopping, this is actually part of this test:
|
// on-going transaction, so it does not accept new invocations."
|
||||||
// "ISPN000217: Received exception from node-8, see cause for remote stack trace
|
// also: org.infinispan.commons.CacheException: java.lang.IllegalStateException: Read commands must ignore leavers
|
||||||
// IllegalLifecycleStateException: ISPN000324: Cache 'clientSessions' is in 'STOPPING' state and this is an invocation not belonging to an
|
if ((ex.getCause() != null && ex.getCause().getMessage().contains("ISPN000324") ||
|
||||||
// on-going transaction, so it does not accept new invocations."
|
(ex instanceof CacheException && ex.getMessage().contains("Read commands must ignore leavers")))) {
|
||||||
if (ex.getCause() != null && ex.getCause().getMessage().contains("ISPN000324")) {
|
log.warn("invocation failed, skipping. Retrying might lead to a 'Unique index or primary key violation' when the offline session has already been stored in the DB in the current session", ex);
|
||||||
log.warn("invocation failed, retrying", ex);
|
} else {
|
||||||
sleep(1000);
|
throw ex;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clientSessionIds.computeIfAbsent(offlineSessionId, a -> new LinkedList<>()).add(clientSessionId);
|
|
||||||
|
// re-initialize the session factory N times in this test
|
||||||
if (index % 100 == 0) {
|
if (index % 100 == 0) {
|
||||||
// don't re-initialize all caches at the same time to avoid an unstable cluster with no leader
|
// don't re-initialize all caches at the same time to avoid an unstable cluster with no leader
|
||||||
// otherwise seen CacheInitializer#loadSessions to loop sleeping
|
// otherwise seen CacheInitializer#loadSessions to loop sleeping
|
||||||
|
|
Loading…
Reference in a new issue