8000 Skip authentication session expiration for realms without authentication sessions by ahus1 · Pull Request #55016 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Skip authentication session expiration for realms without authentication sessions - #55016

Draft
ahus1 wants to merge 2 commits into
keycloak:mainfrom
ahus1:is-55015-skip-auth-session-expiration-empty-realm
Draft

ahus1 wants to merge 2 commits into
keycloak:mainfrom
ahus1:is-55015-skip-auth-session-expiration-empty-realm

Conversation

@ahus1
@ahus1 ahus1 commented Nov 10, 2026 •
Copy link
Copy Markdown
Member

Closes #55015

The expiration first looks for a single root authentication session of the realm with a one-row lookup, and only runs the per-bucket queries if one exists. The lookup is a prefix seek on IDX_ROOT_AUTH_SESSION_REALM, so no schema change is needed.

Decision: nothing is remembered between runs, which is the same pattern as for user sessions in #54886. A remembered "empty since T" mark would have depended on the clock and on node-local state. RealmAwareExpirationTask lets whichever node wins the per-realm check run the realm, so such a mark would only help while the same node keeps winning.

Trade-off: realms that do have sessions run one extra cheap query per run, 65 instead of 64. The saving is for realms without sessions, which go from 64 queries to 1. Authentication sessions are short-lived, so the benefit depends on how many realms are idle. This is an enhancement, not a regression, as JPA authentication sessions did not exist before 26.8.

Assumption: the probe runs in the single transaction of the expiration action, so no separate transaction is needed, unlike for user sessions.

The integration test runs in the stateless test suite, as JPA authentication sessions need that feature. It uses Hibernate statistics, which are shared with the periodic expiration task, so it asserts on query kinds and retries up to three times. It fails without the fix.

…ion sessions

Closes keycloak#55015

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

Closes keycloak#55015

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5264

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip authentication session expiration for realms without authentication sessions

1 participant

0