Skip to content

Disable Hibernate second-level cache to avoid SimpleTimestamper busy loop - #55302

Merged
ahus1 merged 1 commit into
keycloak:mainfrom
ahus1:is-55297-disable-hibernate-second-level-cache
Nov 19, 2026
Merged

ahus1 merged 1 commit into
keycloak:mainfrom
ahus1:is-55297-disable-hibernate-second-level-cache

Conversation

@ahus1

@ahus1 ahus1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Closes #55297

Keycloak caches in Infinispan and uses no Hibernate entity, collection or query caches, so disabling them removes the SimpleTimestamper code path without a functional loss.

Decisions and assumptions:

  • Setting quarkus.hibernate-orm.second-level-caching-enabled=false disables both second-level and query cache, so Quarkus selects NoCachingRegionFactory instead of JCacheRegionFactory. I verified this on a local distribution via the loaded classes.
  • The root cause in Hibernate (SimpleTimestamper.next() spinning when the clock moves backwards) remains upstream (https://hibernate.atlassian.net/browse/HHH-13664, open since 2019); this only avoids it for Keycloak.
  • Listed as a notable change as custom extensions relying on Hibernate caching would need to re-enable it, and it is a build-time option.
  • No automated test added; the effect is a build-time Quarkus setting.

@ahus1
ahus1 force-pushed the is-55297-disable-hibernate-second-level-cache branch from e74113a to 99f4120 Compare November 18, 2026 10:21
…loop

Closes keycloak#55297

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change to disable Hibernate caching by default.

No open issues 🎉

What changed in this PR

Disables Hibernate caching by default to avoid the SimpleTimestamper busy loop after a system-clock rollback reported in #55297. Keycloak’s separate Infinispan caching remains unchanged.

Changes:

  • Disables Hibernate’s second-level and query caches through Quarkus configuration.
  • Adds an upgrade note explaining the impact and how custom extensions can re-enable caching at build time.
File Description
quarkus/​runtime/​src/​main/​resources/​application.properties Disables Hibernate caching and documents the clock-rollback workaround.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Explains the new default and the configuration and rebuild steps for extensions that need caching.

Review effort: Balanced

@ahus1
ahus1 marked this pull request as ready for review November 18, 2026 12:19
@ahus1
ahus1 requested review from a team as code owners November 18, 2026 12:19
@ahus1
ahus1 enabled auto-merge (squash) November 18, 2026 12:19
@ahus1
ahus1 merged commit d287eb2 into keycloak:main Nov 19, 2026
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High CPU usage after system clock rollback - threads spinning in Hibernate SimpleTimestamper.next() (Keycloak 26.8.2)

3 participants