Repository navigation
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
authorization-services
Bug Description
After upgrading to Keycloak 26.8.2, we observed extremely high CPU usage when the Windows system clock is manually adjusted backwards while Keycloak is running.
The issue is reproducible and appears to be related to Hibernate timestamp generation.
After the clock rollback:
CPU usage rapidly increases
Multiple request-processing threads become stuck
Narayana Transaction Reaper starts aborting transactions
Keycloak becomes partially unresponsive
Threads continuously consume CPU inside org.hibernate.cache.spi.support.SimpleTimestamper.next()
This behavior did not occur in our previous Keycloak deployment before upgrading.
Version
26.8.2
Regression
- The issue is a regression
Expected behavior
Keycloak should continue operating or fail gracefully after a system clock rollback.
It should not enter a high-CPU state.
Actual behavior
CPU usage increases dramatically.
Several application threads become stuck in:
Java
org.hibernate.cache.spi.support.SimpleTimestamper.next()
Transactions eventually time out and are cancelled by Narayana Transaction Reaper.
Example warnings:
Plain Text
ARJUNA012117: TransactionReaper::check processing TX ... in state RUN
ARJUNA012095: Abort of action id ... invoked while multiple threads active within it.
ARJUNA012381: Action id ... completed with multiple threads
How to Reproduce?
Start Keycloak 26.8.2.
Access Keycloak normally (Admin Console or OIDC login request).
While Keycloak is running, manually change the Windows system time backwards. For example:
2026-11-18 -> 2007-01-18
Send any request to Keycloak.
Anything else?
Environment
Keycloak: 26.8.2
JDK: SapMachine 21.0.13
OS: Windows Server
System clock was moved backwards during runtime.
"executor-thread-1"
cpu=89296ms
at org.hibernate.cache.spi.support.SimpleTimestamper.next(SimpleTimestamper.java:35)
at org.hibernate.cache.spi.AbstractRegionFactory.nextTimestamp(AbstractRegionFactory.java:146)
at org.hibernate.cache.spi.AbstractCacheTransactionSynchronization.(AbstractCacheTransactionSynchronization.java:17)
at org.hibernate.cache.spi.StandardCacheTransactionSynchronization.(StandardCacheTransactionSynchronization.java:12)
at org.hibernate.cache.spi.AbstractRegionFactory.createTransactionContext(AbstractRegionFactory.java:141)
at org.hibernate.internal.AbstractSharedSessionContract.(AbstractSharedSessionContract.java:215)
at org.hibernate.internal.SessionImpl.(SessionImpl.java:188)
at org.hibernate.internal.SessionFactoryImpl.createEntityManager(...)
at org.keycloak.quarkus.runtime.storage.database.jpa.AbstractJpaConnectionProviderFactory.createEntityManager(...)
at org.keycloak.events.jpa.JpaEventStoreProviderFactory.create(...)
at org.keycloak.services.resources.RealmsResource.getProtocol(...)
"executor-thread-3"
cpu=84359ms
at org.hibernate.cache.spi.support.SimpleTimestamper.next(SimpleTimestamper.java:35)
at org.hibernate.cache.spi.AbstractRegionFactory.nextTimestamp(AbstractRegionFactory.java:146)
...
at org.keycloak.protocol.oidc.endpoints.AuthorizationEndpoint.process(...)
"executor-thread-4"
cpu=80687ms
at org.hibernate.cache.spi.support.SimpleTimestamper.next(SimpleTimestamper.java:35)
at org.hibernate.cache.spi.AbstractRegionFactory.nextTimestamp(AbstractRegionFactory.java:146)
...
at org.keycloak.services.resources.RealmsResource.getProtocol(...)
"user-session-purge-expired"
cpu=37890ms
at org.hibernate.cache.spi.support.SimpleTimestamper.next(SimpleTimestamper.java:35)
at org.hibernate.cache.spi.AbstractRegionFactory.nextTimestamp(AbstractRegionFactory.java:146)
...
at org.keycloak.models.sessions.infinispan.expiration.BaseExpirationTask.purgeExpired(BaseExpirationTask.java:93)
Thread dump timestamp:
1994-01-18 14:41:34
Full thread dump captured after system clock rollback.
Metadata
Metadata
Assignees
Labels
Type
Fields
Projects
- StatusShow more project fieldsDone
Activity
ahus1 commentedon Nov 18, 2026
Thanks for the detailed report.
The stack trace points at Hibernate's
SimpleTimestamper.next(), which loops forever once the system clock is behind the last value it handed out.I'll plan to raise an issue with the Hibernate team for that.Issue already existed: https://hibernate.atlassian.net/browse/HHH-13664Keycloak doesn't use Hibernate's second-level or query cache, but Quarkus enables it by default (
JCacheRegionFactory), and that's what pulls inSimpleTimestamper.I verified locally that disabling it avoids the code path: with
quarkus.hibernate-orm.second-level-caching-enabled=false,NoCachingRegionFactoryis used instead, and it just returnsSystem.currentTimeMillis().Workaround for existing installations:
conf/quarkus.properties:kc.sh build(it is a build-time option), then restart.Please let me know if this works.
Can you please provide more context how the clock rollback happend?
Disable Hibernate second-level cache to avoid SimpleTimestamper busy …
Disable Hibernate second-level cache to avoid SimpleTimestamper busy …
AlvinDroid commentedon Nov 19, 2026
Thanks for the analysis and the suggested workaround.
Regarding the clock rollback, we were able to reproduce the issue in our automated test environment. As part of certain test scenarios, we intentionally revert the system time to a predefined earlier timestamp. This is required to validate documents and date-dependent processes under specific historical dates.
Disable Hibernate second-level cache to avoid SimpleTimestamper busy …
ahus1 commentedon Nov 19, 2026
@AlvinDroid - thank you for the update. This will be backported to an older patch release eventually. You'll see that the labels of the issue will eventually change from "backport" to "release".
laszlojordan-gehc commentedon Nov 26, 2026
The suggested fix did not work for me.
I've set quarkus.hibernate-orm.second-level-caching-enabled=false in quarkus.properties, but still get
org.hibernate.cache.spi.AbstractRegionFactory.nextTimestamp(AbstractRegionFactory.java:146)
org.hibernate.cache.spi.AbstractCacheTransactionSynchronization.(AbstractCacheTransactionSynchronization.java:17)
org.hibernate.cache.spi.StandardCacheTransactionSynchronization.(StandardCacheTransactionSynchronization.java:12)
org.hibernate.cache.spi.AbstractRegionFactory.createTransactionContext(AbstractRegionFactory.java:141)
org.hibernate.internal.AbstractSharedSessionContract.(AbstractSharedSessionContract.java:215)
org.hibernate.internal.SessionImpl.(SessionImpl.java:188)
org.hibernate.internal.SessionFactoryImpl$1.createSession(SessionFactoryImpl.java:551)
org.hibernate.engine.creation.internal.SessionBuilderImpl.openSession(SessionBuilderImpl.java:157)
org.hibernate.internal.SessionFactoryImpl.buildEntityManager(SessionFactoryImpl.java:664)
org.hibernate.internal.SessionFactoryImpl.createEntityManager(SessionFactoryImpl.java:686)
org.hibernate.internal.SessionFactoryImpl.createEntityManager(SessionFactoryImpl.java:158)
org.hibernate.SessionFactory_bWqb48C8SDAAD789_QfkSuCO_7Q_Synthetic_ClientProxy.createEntityManager(Unknown Source)
org.keycloak.quarkus.runtime.storage.database.jpa.AbstractJpaConnectionProviderFactory.createEntityManager(AbstractJpaConnectionProviderFactory.java:121)
org.keycloak.quarkus.runtime.storage.database.jpa.AbstractJpaConnectionProviderFactory.create(AbstractJpaConnectionProviderFactory.java:56)
org.keycloak.quarkus.runtime.storage.database.jpa.NamedJpaConnectionProviderFactory.create(NamedJpaConnectionProviderFactory.java:67)
org.keycloak.quarkus.runtime.storage.database.jpa.NamedJpaConnectionProviderFactory.create(NamedJpaConnectionProviderFactory.java:36)
org.keycloak.services.DefaultKeycloakSession.getOrCreateProvider(DefaultKeycloakSession.java:214)
org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:224)
com.gehc.vp6.usermanagement.keycloak.jpa.infrastructure.BaseEntityManager.(BaseEntityManager.java:35)
com.gehc.vp6.usermanagement.keycloak.jpa.infrastructure.managers.VPSecuritySettingsEntityManager.(VPSecuritySettingsEntityManager.java:34)
com.gehc.vp6.usermanagement.keycloak.domain.providers.handlers.VPLastLoginSettingsHandler.(VPLastLoginSettingsHandler.java:31)
com.gehc.vp6.usermanagement.keycloak.domain.providers.services.VPPasswordSettingsService.(VPPasswordSettingsService.java:58)
com.gehc.vp6.usermanagement.keycloak.domain.providers.ResourcesProvider.getVpPasswordSettingsService(ResourcesProvider.java:78)
com.gehc.vp6.usermanagement.keycloak.domain.providers.ResourcesProvider$quarkusrestinvoker$getVpPasswordSettingsService_1d2dc737436da8a2d9194dcecd97f0922edad606.invoke(Unknown Source)
org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
org.keycloak.quarkus.runtime.integration.resteasy.TransactionalSessionHandler.handle(TransactionalSessionHandler.java:85)
io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:195)
org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:150)
io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:695)
org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
java.base/java.lang.Thread.run(Unknown Source)