KEYCLOAK-12674 Performance degradation after upgrade to Keycloak 8 (#6685)

This commit is contained in:
Tomas Kyjovsky 2020-01-21 19:43:25 +01:00 committed by Marek Posolda
parent 910324e4eb
commit 36eba64f07
2 changed files with 11 additions and 2 deletions

View file

@ -1232,9 +1232,10 @@ public class RealmAdapter implements CachedRealmModel {
return cached.getExecutionsById().get(id); return cached.getExecutionsById().get(id);
} }
@Override
public AuthenticationExecutionModel getAuthenticationExecutionByFlowId(String flowId) { public AuthenticationExecutionModel getAuthenticationExecutionByFlowId(String flowId) {
getDelegateForUpdate(); if (isUpdated()) return updated.getAuthenticationExecutionByFlowId(flowId);
return updated.getAuthenticationExecutionByFlowId(flowId); return cached.getAuthenticationExecutionByFlowId(flowId);
} }
@Override @Override

View file

@ -120,6 +120,7 @@ public class CachedRealm extends AbstractExtendableRevisioned {
protected Map<String, RequiredActionProviderModel> requiredActionProvidersByAlias = new HashMap<>(); protected Map<String, RequiredActionProviderModel> requiredActionProvidersByAlias = new HashMap<>();
protected MultivaluedHashMap<String, AuthenticationExecutionModel> authenticationExecutions = new MultivaluedHashMap<>(); protected MultivaluedHashMap<String, AuthenticationExecutionModel> authenticationExecutions = new MultivaluedHashMap<>();
protected Map<String, AuthenticationExecutionModel> executionsById = new HashMap<>(); protected Map<String, AuthenticationExecutionModel> executionsById = new HashMap<>();
protected Map<String, AuthenticationExecutionModel> executionsByFlowId = new HashMap<>();
protected AuthenticationFlowModel browserFlow; protected AuthenticationFlowModel browserFlow;
protected AuthenticationFlowModel registrationFlow; protected AuthenticationFlowModel registrationFlow;
@ -256,6 +257,9 @@ public class CachedRealm extends AbstractExtendableRevisioned {
for (AuthenticationExecutionModel execution : model.getAuthenticationExecutions(flow.getId())) { for (AuthenticationExecutionModel execution : model.getAuthenticationExecutions(flow.getId())) {
authenticationExecutions.add(flow.getId(), execution); authenticationExecutions.add(flow.getId(), execution);
executionsById.put(execution.getId(), execution); executionsById.put(execution.getId(), execution);
if (execution.getFlowId() != null) {
executionsByFlowId.put(execution.getFlowId(), execution);
}
} }
} }
@ -585,6 +589,10 @@ public class CachedRealm extends AbstractExtendableRevisioned {
return authenticationExecutions; return authenticationExecutions;
} }
public AuthenticationExecutionModel getAuthenticationExecutionByFlowId(String flowId) {
return executionsByFlowId.get(flowId);
}
public Map<String, AuthenticationExecutionModel> getExecutionsById() { public Map<String, AuthenticationExecutionModel> getExecutionsById() {
return executionsById; return executionsById;
} }