Repository navigation
Avoid updates to IDX_USER_SESSION_EXPIRATION_LAST_REFRESH on every token refresh - #51904
Merged
ahus1 merged 5 commits intoAug 26, 2026
Merged
Conversation
…ken refresh Closes keycloak#51900 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
ahus1
force-pushed
the
is-51900-fewer-updates-to-last-update-in-index
branch
from
August 20, 2026 17:09
1a86e67 to
e266551
Compare
…taggering instead Closes keycloak#51900 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces coarse-grained session refresh timestamps to reduce expiration-index updates and database write amplification.
Changes:
- Adds coarse refresh calculation and persistence.
- Reworks expiration cleanup to verify coarse-index candidates.
- Migrates the schema and documents the new index structure.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
SessionExpirationUtils.java |
Calculates staggered coarse timestamps. |
UserSessionPersisterProvider.java |
Deprecates the bulk refresh API. |
PersistentUserSessionModel.java |
Adds coarse refresh accessors. |
PersistentUserSessionAdapter.java |
Updates coarse values during refresh. |
jpa-changelog-26.8.0.xml |
Adds the column and rebuilds the index. |
UserSessionExpirationLogic.java |
Implements two-pass expiration cleanup. |
PersistentUserSessionEntity.java |
Maps the column and updates queries. |
JpaUserSessionPersisterProvider.java |
Persists coarse refresh values. |
ImmutablePersistentUserSessionEntity.java |
Implements the extended model contract. |
JpaChangesPerformer.java |
Supplies realm configuration during persistence. |
changes-26_8_0.adoc |
Documents the schema change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
ahus1
force-pushed
the
is-51900-fewer-updates-to-last-update-in-index
branch
4 times, most recently
from
August 23, 2026 08:48
9d3029b to
73b6511
Compare
Closes keycloak#51968 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com> Fix assume with RunOnServer Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com> Fixing tests Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
ahus1
force-pushed
the
is-51900-fewer-updates-to-last-update-in-index
branch
from
August 23, 2026 09:22
73b6511 to
47ebc9b
Compare
Member
Author
|
@pruivo - please review when you have the time. Thanks! |
pruivo
approved these changes
Aug 25, 2026
ahus1
enabled auto-merge (squash)
August 25, 2026 10:16
stianst
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #51900
I did a minimal local performance test with MSSQL - just counting the updates on tables, not so much measuring congestion:
Before:
IDX_USER_SESSION_EXPIRATION_LAST_REFRESHhad 15020 leaf_inserts_deltaAfter:
IDX_USER_SESSION_EXPIRATION_LAST_REFRESHhad 1502 leaf_inserts_delta, matching the number of logins performed.The log volume didn't reduce much (66584 -> 62756).
As I was comparing with 26.7.3, I saw that
IDX_OFFLINE_USS_BY_BROKER_SESSION_IDnow has zero leaf_inserts_delta due to the filtering applied.I also asked:
Then Claude replied:
I also asked:
and Claude responded:
After testing on PostgreSQL, I saw 99%+ hot updates on the offline user session table, where before I didn't see any hot updates due to updates to the indexed column.
SQL statement to extract the data on MSSQL:
Statement to extract the data on PostgreSQL: