-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
infinispan
Describe the bug
When an entity is created in a transaction and deleted in the same transaction, the entity is marked and transient, and no operation is performed in the Infinispan cache.
However, if the entity is "deleted" twice (or more), the second time resets the transient status; a remove operation is executed in the Infinispan cache. Although not wrong, it is a waste since there is nothing to remove.
It happens in the method below:
keycloak/services/src/main/java/org/keycloak/services/managers/AuthenticationSessionManager.java
Lines 272 to 282 in a659c8d
public boolean removeTabIdInAuthenticationSession(RealmModel realm, AuthenticationSessionModel authSession) { | |
RootAuthenticationSessionModel rootAuthSession = authSession.getParentSession(); | |
rootAuthSession.removeAuthenticationSessionByTabId(authSession.getTabId()); | |
if (rootAuthSession.getAuthenticationSessions().isEmpty()) { | |
// no more tabs, remove the session completely | |
removeAuthenticationSession(realm, authSession, true); | |
return true; | |
} else { | |
return false; | |
} | |
} |
The method removeAuthenticationSessionByTabId()
deletes the entity on the last authentication session, but the AuthenticationSessionManager
invokes the removal again.
Version
main
Regression
- The issue is a regression
Expected behavior
No remove operation is expected in the Infinispan cache.
Actual behavior
Keycloak tries to remove an inexisting session.
How to Reproduce?
Remove an entity twice and count the number of operations executed in the Infinispan cache. It should be zero. I'll add a test for it.
Anything else?
It is the possible cause of the random failures in the cross-site test ConcurrentModificationTest
.
See: keycloak/keycloak-benchmark#1055