Skip to content

(KC26) Use Dedicated SQL Session for Truststore#23

Merged
JBWatenbergScality merged 4 commits intomainfrom
bugfix/flush-during-cascade-latest
Feb 25, 2026
Merged

(KC26) Use Dedicated SQL Session for Truststore#23
JBWatenbergScality merged 4 commits intomainfrom
bugfix/flush-during-cascade-latest

Conversation

@JBWatenbergScality
Copy link
Copy Markdown
Contributor

@JBWatenbergScality JBWatenbergScality commented Dec 19, 2025

Context:
JDBC Connection gets closed under load after some time.

What Changed:
Replace retry/cache complexity with executeInNewSession for reads
getCertificates() and getCertificates(boolean) now always execute in a
fresh Keycloak session via KeycloakModelUtils.runJobInTransaction(),
obtaining a new JDBC connection from the pool. This replaces the
previous approach of em.clear() (which did not reset the connection),
manual retry loops, flush mode manipulation, and in-memory cache
fallback — none of which reliably handled the cold-start case where the
current session's connection is closed.

How was it validated
1000/1000, 0 failures on KC26. The executeInNewSession fix is validated on Keycloak 26.2.0.

JBWatenbergScality and others added 4 commits December 19, 2025 11:56
getCertificates() and getCertificates(boolean) now always execute in a
fresh Keycloak session via KeycloakModelUtils.runJobInTransaction(),
obtaining a new JDBC connection from the pool. This replaces the
previous approach of em.clear() (which did not reset the connection),
manual retry loops, flush mode manipulation, and in-memory cache
fallback — none of which reliably handled the cold-start case where the
current session's connection is closed.

Verified 1000/1000 under concurrent load (10 workers, no delay).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@JBWatenbergScality JBWatenbergScality changed the title Try fixing the flush mode issue (KC26) Use Dedicated SQL Session for Truststore Feb 25, 2026
@JBWatenbergScality JBWatenbergScality merged commit 29dd641 into main Feb 25, 2026
6 checks passed
@JBWatenbergScality JBWatenbergScality deleted the bugfix/flush-during-cascade-latest branch February 25, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant