Upgrading 14.0->15.1. MSSQL issue

Hi
We are trying to upgrade Keycloak from 14.0 to 15.1 but after all steps are complete, the database upgrade is failing with: META-INF/jpa-changelog-master.xml : Index Exists Precondition: IDX_CLIENT_ATT_BY_NAME_VALUE on CLIENT_ATTRIBUTES : Unknown constraint type: 3

We are running MSSQL: SQL Server 15.0.4138.2
I have tried the following JDBC connectors:

  • mssql-jdbc-9.4.0.jre8.jar
  • mssql-jdbc-6.4.0.jre8.jar
  • mssql-jdbc-6.2.2.jre8.jar
  • mssql-jdbc-7.0.0.jre8.jar

Edit: Is it related to this liquidbase bug?

Setting migrationStrategy to manual does not help, and it generates an almost empty .sql file before crashing with the following:

2021-08-12 10:58:58,769 ERROR [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool -- 62) Change Set META-INF/jpa-changelog-14.0.0.xml::14.0.0-KEYCLOAK-18286-revert::keycloak failed.  Error: Migration failed for change set META-INF/jpa-changelog-14.0.0.xml::14.0.0-KEYCLOAK-18286-revert::keycloak:
     Reason: 
          META-INF/jpa-changelog-master.xml : Index Exists Precondition: IDX_CLIENT_ATT_BY_NAME_VALUE on CLIENT_ATTRIBUTES : Unknown constraint type: 3

2021-08-12 10:58:58,769 ERROR [org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider] (ServerService Thread Pool -- 62) Error has occurred while updating the database: liquibase.exception.MigrationFailedException: Migration failed for change set META-INF/jpa-changelog-14.0.0.xml::14.0.0-KEYCLOAK-18286-revert::keycloak:
     Reason: 
          META-INF/jpa-changelog-master.xml : Index Exists Precondition: IDX_CLIENT_ATT_BY_NAME_VALUE on CLIENT_ATTRIBUTES : Unknown constraint type: 3

	at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:541)
	at org.liquibase//liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
	at org.liquibase//liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
	at org.liquibase//liquibase.Liquibase.update(Liquibase.java:214)
	at org.liquibase//liquibase.Liquibase.update(Liquibase.java:277)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.updateChangeSet(LiquibaseJpaUpdaterProvider.java:182)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:103)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.export(LiquibaseJpaUpdaterProvider.java:87)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory$3.run(DefaultJpaConnectionProviderFactory.java:371)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:250)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.export(DefaultJpaConnectionProviderFactory.java:364)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.migration(DefaultJpaConnectionProviderFactory.java:339)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lambda$lazyInit$0(DefaultJpaConnectionProviderFactory.java:184)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:758)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lazyInit(DefaultJpaConnectionProviderFactory.java:135)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:83)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:61)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:316)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:63)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:39)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:316)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.DefaultKeycloakSession.realmLocalStorage(DefaultKeycloakSession.java:228)
	at org.keycloak.keycloak-model-infinispan@15.0.1//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealmDelegate(RealmCacheSession.java:149)
	at org.keycloak.keycloak-model-infinispan@15.0.1//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealm(RealmCacheSession.java:411)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.managers.ApplianceBootstrap.isNewInstall(ApplianceBootstrap.java:46)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication$3.run(KeycloakApplication.java:195)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:250)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication.bootstrap(KeycloakApplication.java:172)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:136)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:250)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:128)
	at org.keycloak.keycloak-wildfly-extensions@15.0.1//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:36)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:114)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2835)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:376)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:288)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:98)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:140)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:42)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at java.base/java.lang.Thread.run(Thread.java:832)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: liquibase.exception.PreconditionErrorException: Precondition Error
	at org.liquibase//liquibase.precondition.core.IndexExistsPrecondition.check(IndexExistsPrecondition.java:121)
	at org.liquibase//liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43)
	at org.liquibase//liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:202)
	at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:498)
	... 69 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Unknown constraint type: 3
	at org.liquibase//liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:178)
	at org.liquibase//liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
	at org.liquibase//liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:246)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:363)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:293)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:267)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:343)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:293)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:267)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:80)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:53)
	at org.liquibase//liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:28)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:150)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:158)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:108)
	at org.liquibase//liquibase.precondition.core.IndexExistsPrecondition.check(IndexExistsPrecondition.java:101)
	... 72 more
Caused by: liquibase.exception.DatabaseException: Unknown constraint type: 3
	at org.liquibase//liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.convertToForeignKeyConstraintType(ForeignKeySnapshotGenerator.java:200)
	at org.liquibase//liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:150)
	... 90 more

2021-08-12 10:58:58,980 FATAL [org.keycloak.services] (ServerService Thread Pool -- 62) Error during startup: java.lang.RuntimeException: Failed to update database
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:118)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.export(LiquibaseJpaUpdaterProvider.java:87)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory$3.run(DefaultJpaConnectionProviderFactory.java:371)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:250)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.export(DefaultJpaConnectionProviderFactory.java:364)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.migration(DefaultJpaConnectionProviderFactory.java:339)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lambda$lazyInit$0(DefaultJpaConnectionProviderFactory.java:184)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:758)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lazyInit(DefaultJpaConnectionProviderFactory.java:135)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:83)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:61)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:316)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:63)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:39)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:316)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.DefaultKeycloakSession.realmLocalStorage(DefaultKeycloakSession.java:228)
	at org.keycloak.keycloak-model-infinispan@15.0.1//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealmDelegate(RealmCacheSession.java:149)
	at org.keycloak.keycloak-model-infinispan@15.0.1//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealm(RealmCacheSession.java:411)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.managers.ApplianceBootstrap.isNewInstall(ApplianceBootstrap.java:46)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication$3.run(KeycloakApplication.java:195)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:250)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication.bootstrap(KeycloakApplication.java:172)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:136)
	at org.keycloak.keycloak-server-spi-private@15.0.1//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:250)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:128)
	at org.keycloak.keycloak-wildfly-extensions@15.0.1//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:36)
	at org.keycloak.keycloak-services@15.0.1//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:114)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2835)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:376)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:288)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:98)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:140)
	at org.jboss.resteasy.resteasy-jaxrs@3.15.1.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:42)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
	at io.undertow.servlet@2.2.5.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
	at org.wildfly.extension.undertow@23.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at java.base/java.lang.Thread.run(Thread.java:832)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set META-INF/jpa-changelog-14.0.0.xml::14.0.0-KEYCLOAK-18286-revert::keycloak:
     Reason: 
          META-INF/jpa-changelog-master.xml : Index Exists Precondition: IDX_CLIENT_ATT_BY_NAME_VALUE on CLIENT_ATTRIBUTES : Unknown constraint type: 3

	at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:541)
	at org.liquibase//liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
	at org.liquibase//liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
	at org.liquibase//liquibase.Liquibase.update(Liquibase.java:214)
	at org.liquibase//liquibase.Liquibase.update(Liquibase.java:277)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.updateChangeSet(LiquibaseJpaUpdaterProvider.java:182)
	at org.keycloak.keycloak-model-jpa@15.0.1//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:103)
	... 63 more
Caused by: liquibase.exception.PreconditionErrorException: Precondition Error
	at org.liquibase//liquibase.precondition.core.IndexExistsPrecondition.check(IndexExistsPrecondition.java:121)
	at org.liquibase//liquibase.precondition.core.AndPrecondition.check(AndPrecondition.java:43)
	at org.liquibase//liquibase.precondition.core.PreconditionContainer.check(PreconditionContainer.java:202)
	at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:498)
	... 69 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Unknown constraint type: 3
	at org.liquibase//liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:178)
	at org.liquibase//liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
	at org.liquibase//liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:246)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:363)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:293)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:267)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:343)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:293)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:267)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:80)
	at org.liquibase//liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:53)
	at org.liquibase//liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:28)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:150)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:158)
	at org.liquibase//liquibase.snapshot.SnapshotGeneratorFactory.has(SnapshotGeneratorFactory.java:108)
	at org.liquibase//liquibase.precondition.core.IndexExistsPrecondition.check(IndexExistsPrecondition.java:101)
	... 72 more
Caused by: liquibase.exception.DatabaseException: Unknown constraint type: 3
	at org.liquibase//liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.convertToForeignKeyConstraintType(ForeignKeySnapshotGenerator.java:200)
	at org.liquibase//liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:150)
	... 90 more
3 Likes

Got it working while using mssql-jdbc-6.3.2.jre8-preview.jar
As I see it, Liquibase in the past made a temporary fix for a bug in the mssql connector.
The included version of liquibase is 3.5.5. I think they have fixed this in 3.6.3. I didn’t try to upgrade liquibase as there also was a slf4j prereq

Hi,

I am using Keycloak 13.0.1 with MS SQL 14 (via mssql-jdbc-9.2.1.jre11.jar) and reading such posts as yours makes me hesitate to update Keycloak to a newer version.

Is there any chance to get that bug-fixing liquibase version included in Keycloak, so that MS SQL users can upgrade to KC 14/15/…? Liquibase 3.5.5 is very old and downgrading the used MS SQL JDBC adapter to such an old version is the wrong direction, I think. Changing the DB is also not an option.

regards,
Matthias

1 Like

I have faced with the same problem and cannot to update from 15.0.0 to 15.0.2.
MSSQL Server is almost latest, 15.0.4123.1 version to be clear.

I have upgraded keycloak from 14.0 to 15.0.0 without any problems. It looks like this problem appears in 15.0.1 version.

Try connector mssql-jdbc-6.3.2.jre8-preview.jar

Seems to be fixed in Keycloak 16:
https://issues.redhat.com/browse/KEYCLOAK-19104

1 Like

Great, I will look forward 16.0 version