[keycloak-user] DefaultKeycloakTransactionManager.begin doesn't call afterCompletion.begin

Adrian Gonzalez adr_gonzalez at yahoo.fr
Fri Feb 9 22:36:59 EST 2018


Hello,
I'm having some issued when deleting a realm containing 20.000 groups (via /realms/{id] REST API).It's just takes some time and the transaction is aborted.
What I tried for the moment, is to write a REST endpoint which deletes the groups in batches.The endpoint begins and commit transaction in a loop (in batches of 100).
What I see is that after the first commit and the second begin, I have a 
|03:18:02,861ERROR[org.keycloak.services.error.KeycloakErrorHandler](defaulttask-14)Uncaughtservererror:java.lang.IllegalStateException:Cannotaccessdelegatewithoutatransaction|atorg.keycloak.models.cache.infinispan.UserCacheSession.getDelegate(UserCacheSession.java:98)|atorg.keycloak.models.cache.infinispan.UserCacheSession.getUsers(UserCacheSession.java:632)|atorg.keycloak.models.cache.infinispan.UserCacheSession.getUsers(UserCacheSession.java:642)|atorg.gonzalad.keycloak.idp.user.rest.BenchmarkResource.deleteRealm(BenchmarkResource.java:88)
This seems to be because DefaultKeycloakTransactionManager.begin() calls only tx.begin of transactions attribute.But it doesn't call the begin() for the prepare nor for the afterCompletion attribute.
And since the UserCacheSession.getDelegate() has registered a callback in the afterCompletion attribute,  UserCacheSession.getDelegate()  isn't aware that I restarted a second transaction.
Should I raise an issue or did I misunderstood the issue ?
ThanksAdrian


More information about the keycloak-user mailing list