Metabase-BI系列05: 错误Unknown system variable 'session_track_schema'

Metabase连接mysql5.6.16-log版本数据库报错:Unknown system variable 'session_track_schema'

情况一:Metabase启动数据库为mysql5.6.16

启动直接报错,启动失败

Metabase在启动时报错session_track_schema,日志文件如下:

while i'm executing
export MB_DB_CONNECTION_URI="mysql://..."; java -jar metabase.jar
with mysql server version of 5.6.16
i've got this exception

05-13 18:58:09 INFO metabase.util :: Loading Metabase...
05-13 18:58:09 INFO metabase.util :: Maximum memory available to JVM: 3.4 GB
05-13 18:59:54 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance. ?
For more information, see https://metabase.com/docs/latest/operations-guide/start.html#encrypting-your-database-connection-details-at-rest
05-13 19:02:25 INFO metabase.driver :: Registered abstract driver :sql ?
05-13 19:07:27 INFO metabase.core :: Starting Metabase in STANDALONE mode
05-13 19:07:30 INFO metabase.server :: Launching Embedded Jetty Webserver with config:
{:port 10080, :host "0.0.0.0"}

05-13 19:07:34 INFO metabase.core :: Starting Metabase version v0.32.7 ([`e309f28`](https://github.com/metabase/metabase/commit/e309f2875ca0ffd87da5fb1666260b0ab257860d) release-0.32.x) ...
05-13 19:07:34 INFO metabase.core :: System timezone is 'Asia/Shanghai' ...
05-13 19:07:34 INFO metabase.plugins :: Loading plugins in /home/lhladmin/metabase/plugins...
05-13 19:07:40 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :hive-like...
05-13 19:07:40 DEBUG plugins.classloader :: Setting current thread context classloader to NEWLY CREATED classloader clojure.lang.DynamicClassLoader@79ca51cb...
05-13 19:07:42 INFO metabase.driver :: Registered abstract driver :sql-jdbc (parents: :sql) ?
Load driver :sql-jdbc took 2 s
05-13 19:07:43 INFO metabase.driver :: Registered abstract driver :hive-like (parents: #{:sql-jdbc}) ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :sparksql...
05-13 19:07:43 INFO metabase.driver :: Registered driver :sparksql (parents: #{:hive-like}) ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :druid...
05-13 19:07:43 INFO metabase.driver :: Registered driver :druid ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :snowflake...
05-13 19:07:43 INFO metabase.driver :: Registered driver :snowflake (parents: #{:sql-jdbc}) ?
05-13 19:07:43 INFO plugins.dependencies :: Metabase cannot initialize plugin Metabase Oracle Driver due to required dependencies. Metabase requires the Oracle JDBC driver in order to connect to Oracle databases, but we can't ship it as part of Metabase due to licensing restrictions. See https://metabase.com/docs/latest/administration-guide/databases/oracle.html for more details.

05-13 19:07:43 INFO plugins.dependencies :: Metabase Oracle Driver dependency {:class oracle.jdbc.OracleDriver} satisfied? false
05-13 19:07:43 INFO plugins.dependencies :: Plugins with unsatisfied deps: ["Metabase Oracle Driver"]
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :google...
05-13 19:07:43 INFO metabase.driver :: Registered abstract driver :google ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :presto...
05-13 19:07:43 INFO metabase.driver :: Registered driver :presto (parents: #{:sql}) ?
05-13 19:07:43 INFO plugins.dependencies :: Metabase cannot initialize plugin Metabase Vertica Driver due to required dependencies. Metabase requires the Vertica JDBC driver in order to connect to Vertica databases, but we can't ship it as part of Metabase due to licensing restrictions. See https://metabase.com/docs/latest/administration-guide/databases/vertica.html for more details.

05-13 19:07:43 INFO plugins.dependencies :: Metabase Vertica Driver dependency {:class com.vertica.jdbc.Driver} satisfied? false
05-13 19:07:43 INFO plugins.dependencies :: Plugins with unsatisfied deps: ["Metabase Vertica Driver" "Metabase Oracle Driver"]
05-13 19:07:43 INFO plugins.dependencies :: Plugin 'Metabase BigQuery Driver' depends on plugin 'Metabase Google Drivers Shared Dependencies'05-13 19:07:43 INFO plugins.dependencies :: Metabase BigQuery Driver dependency {:plugin Metabase Google Drivers Shared Dependencies} satisfied? true
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :bigquery...
05-13 19:07:43 INFO metabase.driver :: Registered driver :bigquery (parents: #{:sql :google}) ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :sqlite...
05-13 19:07:43 INFO metabase.driver :: Registered driver :sqlite (parents: #{:sql-jdbc}) ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :sqlserver...
05-13 19:07:43 INFO metabase.driver :: Registered driver :sqlserver (parents: #{:sql-jdbc}) ?
05-13 19:07:43 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :redshift...
05-13 19:07:43 INFO metabase.driver :: Registered driver :postgres (parents: :sql-jdbc) ?
Load driver :postgres took 1 s
05-13 19:07:44 INFO metabase.driver :: Registered driver :redshift (parents: #{:postgres}) ?
05-13 19:07:44 INFO plugins.dependencies :: Plugin 'Metabase Google Analytics Driver' depends on plugin 'Metabase Google Drivers Shared Dependencies'
05-13 19:07:44 INFO plugins.dependencies :: Metabase Google Analytics Driver dependency {:plugin Metabase Google Drivers Shared Dependencies} satisfied? true
05-13 19:07:44 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :googleanalytics...
05-13 19:07:44 INFO metabase.driver :: Registered driver :googleanalytics (parents: #{:google}) ?
05-13 19:07:44 INFO plugins.lazy-loaded-driver :: Registering lazy loading driver :mongo...
05-13 19:07:44 INFO metabase.driver :: Registered driver :mongo ?
05-13 19:07:46 INFO metabase.driver :: Registered driver :mysql (parents: :sql-jdbc) ?
Load driver :mysql took 2 s
05-13 19:07:48 INFO metabase.driver :: Registered driver :h2 (parents: :sql-jdbc) ?
Load driver :h2 took 1 s
05-13 19:07:49 INFO metabase.core :: Setting up and migrating Metabase DB. Please sit tight, this may take a minute...
05-13 19:07:49 INFO metabase.db :: Verifying mysql Database Connection ...
05-13 19:07:49 INFO metabase.driver :: Initializing driver :sql...
05-13 19:07:49 INFO metabase.driver :: Initializing driver :sql-jdbc...
05-13 19:07:49 INFO metabase.driver :: Initializing driver :mysql...
05-13 19:07:52 ERROR metabase.core :: Metabase Initialization FAILED
java.lang.Exception: java.sql.SQLException: Unknown system variable 'session_track_schema'
at metabase.driver.util$can_connect_with_details_QMARK_.invokeStatic(util.clj:34)
at metabase.driver.util$can_connect_with_details_QMARK_.doInvoke(util.clj:18)
at clojure.lang.RestFn.invoke(RestFn.java:442)
at clojure.lang.Var.invoke(Var.java:393)
at metabase.db$verify_db_connection$fn__16148.invoke(db.clj:403)
at metabase.db$verify_db_connection.invokeStatic(db.clj:401)
at metabase.db$verify_db_connection.invoke(db.clj:394)
at metabase.db$verify_db_connection.invokeStatic(db.clj:397)
at metabase.db$verify_db_connection.invoke(db.clj:394)
at metabase.db$setup_db_BANG_$Missing open brace for subscriptfn__16165.invoke(db.clj:467)
at metabase.util$do_with_us_locale.invokeStatic(util.clj:676)
at metabase.util$do_with_us_locale.invoke(util.clj:662)
at metabase.db$setup_db_BANG_.invokeStatic(db.clj:466)
at metabase.db$setup_db_BANG_.doInvoke(db.clj:460)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at metabase.core$init_BANG_.invokeStatic(core.clj:77)
at metabase.core$init_BANG_.invoke(core.clj:56)
at metabase.core$start_normally.invokeStatic(core.clj:123)
at metabase.core$start_normally.invoke(core.clj:117)
at metabase.core$*main.invokeStatic(core.clj:143)
at metabase.core$\*main.doInvoke(core.clj:138)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at metabase.core.main(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: java.sql.SQLException: Unknown system variable 'session_track_schema'
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:206)
at clojure.core$deref_future.invokeStatic(core.clj:2302)
at clojure.core$future_call$Missing open brace for subscriptreify__8439.deref(core.clj:6974)
at clojure.core$deref.invokeStatic(core.clj:2324)
at clojure.core$deref.invoke(core.clj:2306)
at metabase.util$deref_with_timeout.invokeStatic(util.clj:328)
at metabase.util$deref_with_timeout.invoke(util.clj:324)
at metabase.driver.util$can_connect_with_details_QMARK\*.invokeStatic(util.clj:29)
... 24 more
Caused by: java.sql.SQLException: Unknown system variable 'session_track_schema'
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:255)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:165)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1199)
at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:560)
at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:174)
at org.mariadb.jdbc.Driver.connect(Driver.java:92)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at clojure.java.jdbc$get_driver_connection.invokeStatic(jdbc.clj:271)
at clojure.java.jdbc$get_driver_connection.invoke(jdbc.clj:250)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:411)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:274)
at clojure.java.jdbc$db_query_with_resultset_STAR*.invokeStatic(jdbc.clj:1093)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1075)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1164)
at clojure.java.jdbc$query.invoke(jdbc.clj:1126)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1142)
at clojure.java.jdbc$query.invoke(jdbc.clj:1126)
at metabase.driver.sql_jdbc.connection$can_connect_QMARK_.invokeStatic(connection.clj:123)
at metabase.driver.sql_jdbc.connection$can_connect_QMARK_.invoke(connection.clj:118)
at metabase.driver.sql_jdbc$Missing open brace for subscriptfn__62793.invokeStatic(sql_jdbc.clj:39)
at metabase.driver.sql_jdbc$fn__62793.invoke(sql_jdbc.clj:38)
at clojure.lang.MultiFn.invoke(MultiFn.java:234)
at metabase.driver.util$can_connect_with_details_QMARK_$Missing open brace for subscriptfn__18037.invoke(util.clj:30)
at clojure.core$binding_conveyor_fn$Missing open brace for subscriptfn__5739.invoke(core.clj:2030)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: Unknown system variable 'session_track_schema'
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1587)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1445)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1407)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.additionalData(AbstractConnectProtocol.java:730)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connect(AbstractConnectProtocol.java:542)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1195)
... 27 more
05-13 19:07:52 INFO metabase.core :: Metabase Shutting Down ...
05-13 19:07:52 INFO metabase.server :: Shutting Down Embedded Jetty Webserver
05-13 19:07:53 INFO metabase.core :: Metabase Shutdown COMPLETE

情况二:添加数据源mysql5.6.16

如果数据源是这个版本也会同样的问题:

5.6.16

这个问题是数据库版本导致的,你看一下详细查看Metabase github的issue:9483的讨论

关于这个问题Metabase上的issue特别的多,而且容易看晕,最后终于在找到了一个解决办法,亲测可用

最终解决方案,你可以看一下(见issue:9954):

分析原因-session-track-schema

至于MariaDB是MySQL 的一个 branch,还是MariaDB 是 MySQL 的一个fork先不讨论,不过它俩似乎一直就存在兼容性的问题,Metabase MySQL/MariaDB driver是mariadb-java-client这个包。

Metabase不支持Alibaba RDS MySQL 5.6.16-log,因为在0.32.0版本中更改为MariaDB Connector/J,因为旧MySQL不支持session-track-schema。

后来发现就是这个5.6.16-log这个小版本有问题,目前其他的版本未发现存在问题。

解决办法-mariadb-java-client包

首先确定Metabase使用的MySQL/MariaDB driver版本,到project下面

[org.mariadb.jdbc/mariadb-java-client "2.3.0"]           ; MySQL/MariaDB driver

需要下载源码包:mariadb-java-client-2.3.0-sources.jar(Metabase当前版本用的这个版本)

AbstractConnectProtocol.java-542行注释掉

if (options.usePipelineAuth && !options.createDatabaseIfNotExist) {
  try {
    sendPipelineAdditionalData();
    readPipelineAdditionalData(serverData);
  } catch (SQLException sqle) {
    if ("08".equals(sqle.getSQLState())) {
      throw sqle;
    }
    //in case pipeline is not supported
    //(proxy flush socket after reading first packet)
    //解决mysql5.6.16-log版本,session_track_schema问题
    //additionalData(serverData);
    }
  } else {
    additionalData(serverData);
  }

编译完替换就重新启动即可,也可以直接下载我编译完的 AbstractConnectProtocol.class

blog链接: https://dumplingbao.github.io/2019/11/29/metabase-bi-bug01/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342