+
Skip to content

Invoking BaseUpdater.markDeleted() more than once cause the transient status to be lost #35570

@pruivo

Description

@pruivo

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:

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载