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

Trouble migrating from 2.5.4 to 3.2.1

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.3.0.CR1
    • Component/s: None
    • Labels:
      None
    • Docs QE Status:
      NEW
    • QE Status:
      VERIFIED

      Description

      I've been trying to migrate a Keycloak instance connected to a MariaDB database from version 2.5.4 to 3.2.1. It keeps choking on the database migration, seemingly because of foreign keys:

      Change Set META-INF/jpa-changelog-3.2.0.xml::3.2.0::keycloak failed. Error:
      Can't create table 'keycloak.#sql-169c4_9444' (errno: 150) [Failed SQL: ALTER TABLE keycloak.CLIENT_INITIAL_ACCESS ADD CONSTRAINT FK_CLIENT_INIT_ACC_REALM FOREIGN KEY (REALM_ID) REFERENCES keycloak.REALM (ID)]: liquibase.exception
      .DatabaseException: Can't create table 'keycloak.#sql-169c4_9444' (errno: 150) [Failed SQL: ALTER TABLE keycloak.CLIENT_INITIAL_ACCESS ADD CONSTRAINT FK_CLIENT_INIT_ACC_REALM FOREIGN KEY (REALM_ID) REFERENCES keycloak.REALM (ID)]
      at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:316)
      at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
      at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
      at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1247)
      at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1230)
      at liquibase.changelog.ChangeSet.execute(ChangeSet.java:548)
      at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
      at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
      at liquibase.Liquibase.update(Liquibase.java:210)
      at liquibase.Liquibase.update(Liquibase.java:190)
      at liquibase.Liquibase.update(Liquibase.java:186)
      at org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.updateChangeSet(LiquibaseJpaUpdaterProvider.java:135)
      at org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:88)
      at org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:67)
      at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.update(DefaultJpaConnectionProviderFactory.java:322)
      at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.migration(DefaultJpaConnectionProviderFactory.java:308)
      at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lambda$lazyInit$0(DefaultJpaConnectionProviderFactory.java:179)
      at org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:544)
      at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lazyInit(DefaultJpaConnectionProviderFactory.java:130)
      at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:78)
      at org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:56)
      at org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:163)
      at org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:51)
      at org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:33)
      at org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:163)
      at org.keycloak.models.cache.infinispan.RealmCacheSession.getDelegate(RealmCacheSession.java:181)
      at org.keycloak.models.cache.infinispan.RealmCacheSession.getMigrationModel(RealmCacheSession.java:174)
      at org.keycloak.migration.MigrationModelManager.migrate(MigrationModelManager.java:70)
      at org.keycloak.services.resources.KeycloakApplication.migrateModel(KeycloakApplication.java:243)
      at org.keycloak.services.resources.KeycloakApplication.migrateAndBootstrap(KeycloakApplication.java:184)


      I've followed the instructions in the migration guide and don't really know what I could be doing wrong here.
      I did set it to manual to check what it tries to execute and noticed that the REALM_ID field on that table allows NULLs, while the REALM table does not. Could that be the problem?
      ​For now I just put restored the DB backup and started 2.5.4.​

      I tried to post this to the user mailing list first, but it got rejected...

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              hmlnarik Hynek Mlnařík
              Reporter:
              gpgekko Guylian Pot (Inactive)
              Tester:
              Vlasta Ramik Vlasta Ramik
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: