我们最近将我们的 Keycloak 服务器从 18 升级到 20。
我们主要使用 MySQL,但对于这个特定实例,我们使用 MariaDB。Keycloak 是使用KC_DB=mysql
, 如果这很重要的话。
现在在新环境中启动后,我们收到此错误消息:
Setting up realm configuration
Importing realm and user in case they don't exist yet
2022-11-12 09:08:10,439 INFO [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: Base URL: <unset>, Hostname: hostname.com, Strict HTTPS: true, Path: <request>, Strict BackChannel: false, Admin URL: <unset>, Admin: <request>, Port: -1, Proxied: true
2022-11-12 09:08:11,815 WARN [io.quarkus.agroal.runtime.DataSources] (main) Datasource <default> enables XA but transaction recovery is not enabled. Please enable transaction recovery by setting quarkus.transaction-manager.enable-recovery=true, otherwise data may be lost if the application is terminated abruptly
2022-11-12 09:08:12,482 WARN [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal
2022-11-12 09:08:12,581 WARN [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
2022-11-12 09:08:12,643 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller 'org.infinispan.jboss.marshalling.core.JBossUserMarshaller'
2022-11-12 09:08:12,998 INFO [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000128: Infinispan version: Infinispan 'Triskaidekaphobia' 13.0.10.Final
2022-11-12 09:08:13,073 WARN [liquibase.database.DatabaseFactory] (main) Unknown database: MySQL
2022-11-12 09:08:14,159 WARN [liquibase.database.DatabaseFactory] (main) Unknown database: MySQL
2022-11-12 09:08:14,183 WARN [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockDatabaseChangeLogGenerator] (main) No direct support for database liquibase.database.core.UnsupportedDatabase . Database lock may not work correctly
2022-11-12 09:08:14,184 WARN [liquibase.database.DatabaseFactory] (main) Unknown database: MySQL
2022-11-12 09:08:14,283 INFO [org.keycloak.quarkus.runtime.storage.legacy.liquibase.QuarkusJpaUpdaterProvider] (main) Updating database. Using changelog META-INF/jpa-changelog-master.xml
2022-11-12 09:08:14,780 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (import_export) mode
2022-11-12 09:08:14,781 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to update database
2022-11-12 09:08:14,781 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: liquibase.exception.MigrationFailedException: Migration failed for change set META-INF/jpa-changelog-20.0.0.xml::client-attributes-string-accomodation-fixed::keycloak:
Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 [Failed SQL: (1064) ALTER TABLE CLIENT_ATTRIBUTES ADD VALUE_NEW CLOB]
2022-11-12 09:08:14,781 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Migration failed for change set META-INF/jpa-changelog-20.0.0.xml::client-attributes-string-accomodation-fixed::keycloak:
Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 [Failed SQL: (1064) ALTER TABLE CLIENT_ATTRIBUTES ADD VALUE_NEW CLOB]
2022-11-12 09:08:14,781 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 [Failed SQL: (1064) ALTER TABLE CLIENT_ATTRIBUTES ADD VALUE_NEW CLOB]
2022-11-12 09:08:14,781 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
2022-11-12 09:08:14,781 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.
我知道“断线”是:
ALTER TABLE CLIENT_ATTRIBUTES ADD VALUE_NEW CLOB
根据 MariaDB 文档,CLOB
只有在 sql_mode=oracle
. 好吧,我们不使用 oracle sql_mode
,所以我尝试将其更改为oracle
. 我是在数据库级别上做的,我知道还有一个全局级别,我还没有接触过。
没有成功。启动后同样的消息。
所以我开始查看更新日志,这里显示NCLOB
的不是.CLOB
NCLOB
知道这里发生了什么吗?
在我们的例子中,我们将 DB 升级设置为手动以获取 keycloak 需要执行的所有查询,然后我们没有创建具有请求类型的 VALUE_NEW 列,而是手动更改 VALUE 的类型并将新数据插入列中。
此外,我们的新类型是 TEXT