Repository navigation
Conversation
…ra queries Closes keycloak#54886 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
2 tasks done
Closes keycloak#54886 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
…ty realms Closes keycloak#54886 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what a
7F39
ppears 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 #54886
Each expiration run first looks for a single session of the realm and type with a one-row index lookup, and only runs the per-bucket queries if one exists. The lookup is a prefix seek on the existing expiration index, so no schema change is needed and the fix can be backported.
Decision: nothing is remembered between runs. An earlier version recorded the time a realm was found empty and skipped it until the idle timeout passed. That saved the probe query, but it depended on the wall clock, on node-local state in a shared singleton, and on the assumption that new sessions never carry a timestamp older than the observation. It was fragile under time offsets and clock changes, and it needed extra guards and tests. The probe costs one query per realm and type per run instead of about 259, which resolves the issue without that risk. A per-bucket high-water mark is tracked in #55012.
Decision: the probe runs in its own short transaction. The expiration runs in an outer transaction while the deletes use inner transactions, and a read in the outer one could hold shared locks under strict isolation levels that the deletes then wait for.
Assumption: for offline sessions the probe does not filter by
REMEMBER_ME, as that column can be true, false or NULL there. The skipped migration of the remember-me flag only concerns regular sessions, which are probed separately.Assumption: the integration test 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.