Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-4789

Can't remove userStorage when linked users have consent

    Details

    • Docs QE Status:
      NEW
    • QE Status:
      VERIFIED

      Description

      • Add LDAP user storage provider
      • Change some client to have "consent required" switch ON
      • Login to specified client from above as some user from LDAP
      • Login to admin console and try to delete LDAP provider. There is an "Unexpected error" with stacktrace in server.log:
        Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
        	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
        	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
        	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1700)
        	at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:70)
        	at org.keycloak.models.jpa.JpaUserProvider.removeImportedUsers(JpaUserProvider.java:433)
        	at org.keycloak.models.jpa.JpaUserProvider.preRemove(JpaUserProvider.java:743)
        	at org.keycloak.storage.UserStorageManager.preRemove(UserStorageManager.java:611)
        	at org.keycloak.models.cache.infinispan.UserCacheSession.preRemove(UserCacheSession.java:871)
        	at org.keycloak.models.jpa.RealmAdapter.removeComponent(RealmAdapter.java:1869)
        	at org.keycloak.models.cache.infinispan.RealmAdapter.removeComponent(RealmAdapter.java:1283)
        	at org.keycloak.services.resources.admin.ComponentResource.removeComponent(ComponentResource.java:197)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:497)
        	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
        	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
        	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
        	at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:138)
        	at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)
        	at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)
        	at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)
        	at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)
        	at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:101)
        	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
        	... 32 more
        Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
        	at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
        	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
        	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
        	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
        	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:207)
        	at org.hibernate.hql.internal.ast.exec.BasicExecutor.doExecute(BasicExecutor.java:91)
        	at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:60)
        	at org.hibernate.hql.internal.ast.exec.DeleteExecutor.execute(DeleteExecutor.java:111)
        	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:429)
        	at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:374)
        	at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1348)
        	at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:102)
        	at org.hibernate.jpa.internal.QueryImpl.internalExecuteUpdate(QueryImpl.java:405)
        	at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:61)
        	... 53 more
        Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`keycloak`.`USER_CONSENT`, CONSTRAINT `FK_GRNTCSNT_USER` FOREIGN KEY (`USER_ID`) REFERENCES `USER_ENTITY` (`ID`))
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        	at com.mysql.jdbc.Util.getInstance(Util.java:386)
        	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)
        	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
        	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
        	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
        	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
        	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
        	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
        	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)
        	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2366)
        	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2350)
        	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)
        	... 62 more
        

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mposolda Marek Posolda
                Reporter:
                mposolda Marek Posolda
                Tester:
                Zuzana Schwarzov√°
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: