Offline User Session dead lock caused by PersisterLastSessionRefreshStore
Issue
Token request failed with with error, and following Deadlock ERROR log was recorded in server.log.
[0m[33m09:58:39,821 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-3567) SQL Error: 1213, SQLState: 40001
[0m[31m09:58:39,821 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-3567) Deadlock found when trying to get lock; try restarting transaction
[0m[31m09:58:39,821 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-3567) Uncaught server error: javax.persistence.OptimisticLockException: org.hibernate.exception.LockAcquisitionException: could not execute statement
at org.hibernate//org.hibernate.internal.ExceptionConverterImpl.wrapLockException(ExceptionConverterImpl.java:277)
at org.hibernate//org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:98)
at org.hibernate//org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate//org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1594)
at org.keycloak.keycloak-model-jpa@9.0.9.redhat-00001//org.keycloak.models.jpa.session.JpaUserSessionPersisterProvider.updateLastSessionRefreshes(JpaUserSessionPersisterProvider.java:213)
at org.keycloak.keycloak-model-infinispan@9.0.9.redhat-00001//org.keycloak.models.sessions.infinispan.changes.sessions.PersisterLastSessionRefreshStore.sendMessage(PersisterLastSessionRefreshStore.java:74)
at org.keycloak.keycloak-model-infinispan@9.0.9.redhat-00001//org.keycloak.models.sessions.infinispan.changes.sessions.AbstractLastSessionRefreshStore.checkSendingMessage(AbstractLastSessionRefreshStore.java:61)
at org.keycloak.keycloak-model-infinispan@9.0.9.redhat-00001//org.keycloak.models.sessions.infinispan.changes.sessions.AbstractLastSessionRefreshStore.putLastSessionRefresh(AbstractLastSessionRefreshStore.java:51)
at org.keycloak.keycloak-model-infinispan@9.0.9.redhat-00001//org.keycloak.models.sessions.infinispan.UserSessionAdapter.setLastSessionRefresh(UserSessionAdapter.java:218)
at org.keycloak.keycloak-services@9.0.9.redhat-00001//org.keycloak.protocol.oidc.TokenManager.refreshAccessToken(TokenManager.java:287)
at org.keycloak.keycloak-services@9.0.9.redhat-00001//org.keycloak.protocol.oidc.endpoints.TokenEndpoint.refreshTokenGrant(TokenEndpoint.java:501)
at org.keycloak.keycloak-services@9.0.9.redhat-00001//org.keycloak.protocol.oidc.endpoints.TokenEndpoint.processGrantRequest(TokenEndpoint.java:188)
Environment
- Red Hat Single Sign-On (RH-SSO)
- 7.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.