[keycloak-dev] deadlocks

Bill Burke bburke at redhat.com
Mon Jun 2 20:51:10 EDT 2014


Ok, I found the problem...

RealmAdapter.getAuthenticationProviders() was sorting the collection 
returned by the realm entity.  If you do this, then Hibernate thinks 
you've modified the collection and it performs an update :)

Can you think of any other places where returned collections are sorted?

On 6/2/2014 8:33 PM, Bill Burke wrote:
> I"m getting concurrent deadlocks when doing a login with multiple
> threads.  Its just bizarre and I don't get it.  Check out this error
> message.  Why the hell would "delete from AuthProviders" be called
> ??????!?!?!?!?!!!  I don't see a setAuthProviders happening anywhere.
>
> Caused by: org.h2.jdbc.JdbcSQLException: Deadlock detected. The current
> transaction was rolled back. Details: "
> Session #8 (user: SA) is waiting to lock PUBLIC.USERSESSIONENTITY while
> locking PUBLIC.AUTHENTICATIONLINKENTITY (exclusive), PUBLIC.USERENTITY
> (exclusive), PUBLIC.AUTHPROVIDERS (exclusive).
> Session #5 (user: SA) is waiting to lock PUBLIC.AUTHPROVIDERS while
> locking PUBLIC.USERSESSIONENTITY (exclusive)."; SQL statement:
> delete from AuthProviders where RealmEntity_id=? [40001-161]
> 	at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
> 	at org.h2.message.DbException.get(DbException.java:169)
> 	at org.h2.message.DbException.get(DbException.java:146)
>
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com


More information about the keycloak-dev mailing list