From 3a9e0513012aaaa574280ed141525fa946ce73a0 Mon Sep 17 00:00:00 2001 From: Stefan Guilhen Date: Wed, 30 Nov 2022 10:15:04 -0300 Subject: [PATCH] Add debug log messages to KeycloakModelUtils.runJobInRetriableTransaction Closes #15749 --- .../java/org/keycloak/models/utils/KeycloakModelUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server-spi-private/src/main/java/org/keycloak/models/utils/KeycloakModelUtils.java b/server-spi-private/src/main/java/org/keycloak/models/utils/KeycloakModelUtils.java index 769b46d4ad..5003d17d7d 100755 --- a/server-spi-private/src/main/java/org/keycloak/models/utils/KeycloakModelUtils.java +++ b/server-spi-private/src/main/java/org/keycloak/models/utils/KeycloakModelUtils.java @@ -17,6 +17,7 @@ package org.keycloak.models.utils; +import org.jboss.logging.Logger; import org.keycloak.Config; import org.keycloak.Config.Scope; import org.keycloak.broker.social.SocialIdentityProvider; @@ -90,6 +91,8 @@ import static org.keycloak.models.Constants.REALM_ATTR_USERNAME_CASE_SENSITIVE_D */ public final class KeycloakModelUtils { + private static final Logger logger = Logger.getLogger(KeycloakModelUtils.class); + public static final String AUTH_TYPE_CLIENT_SECRET = "client-secret"; public static final String AUTH_TYPE_CLIENT_SECRET_JWT = "client-secret-jwt"; @@ -325,6 +328,7 @@ public final class KeycloakModelUtils { if (isExceptionRetriable(re) && ++retryCount < attemptsCount) { int delay = Math.min(retryIntervalMillis * attemptsCount, (1 << retryCount) * retryIntervalMillis) + rand.nextInt(retryIntervalMillis); + logger.debugf("Caught retriable exception, retrying request. Retry count = %s, retry delay = %s", retryCount, delay); try { Thread.sleep(delay); } catch (InterruptedException ie) { @@ -332,6 +336,9 @@ public final class KeycloakModelUtils { throw new RuntimeException(ie); } } else { + if (retryCount == attemptsCount) { + logger.debug("Exhausted all retry attempts for request."); + } throw re; } } finally {