Compatibility of TiDB 7.5 with Metabase: Unable to Create SQL Queries (Using Native SQL for BI Data Queries)

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB 7.5版本对metabase的兼容性,无法创建sql查询问题(使用原生SQL进行BI数据查询)

| username: Hacker_CvvT6v40

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version] v7.5
[Reproduction Path]

  1. Install any version of Metabase using Docker
  2. Enter the admin page, create a database source, select the TiDB data source without any other connection parameters
  3. Create a Metabase question, select SQL query
  4. Write any query, such as SELECT 1
    [Encountered Problem: Issue Phenomenon and Impact]
    Impact: We have been able to use Metabase as a BI tool on TiDB 5.x versions for data presentation to customers. During a redeployment of TiDB 7.5 for a customer, we found that it no longer worked. This has impacted our entire product ecosystem, and we hope the official team can address this compatibility issue in the new version.

Issue Phenomenon: When we create a native SQL query in Metabase and query TiDB version 7.5, we find that the query fails, returning “unexpected end of stream, read 0 bytes from 7 (socket was closed by server).” After multiple attempts to change the Metabase version without success and confirming that TiDB 5.x versions work normally, we believe this issue may be caused by the higher version of TiDB. Metabase had a similar issue in 2019 with a solution provided (link: Metabase 0.32.5 - unexpected end of stream, read 0 bytes from 7 · Issue #9885 · metabase/metabase (github.com), which was automatically resolved in higher versions). However, we have been using Metabase since 2021 without any issues (Metabase subsequently used the MariaDB driver) until we recently started using TiDB version 7.5.

Specific error screenshot for data retrieval failure:

Checked Metabase’s fault log, detailed information as follows:
[6573d47d-4da9-4423-b910-1a79c2275683] 2023-12-23T23:03:23+08:00 ERROR metabase.query-processor.middleware.catch-exceptions Error processing query: unexpected end of stream, read 0 bytes from 7 (socket was closed by server)
{:database_id 3,
:started_at #t “2023-12-23T15:03:23.633626Z[GMT]”,
:via
[{:status :failed,
:class java.sql.SQLNonTransientConnectionException,
:error “unexpected end of stream, read 0 bytes from 7 (socket was closed by server)”,
:stacktrace
[“org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.handleIoException(AbstractQueryProtocol.java:2089)”
“org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1539)”
“org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1518)”
“org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:257)”
“org.mariadb.jdbc.MariaDbStatement.executeInternal(MariaDbStatement.java:356)”
“org.mariadb.jdbc.MariaDbStatement.execute(MariaDbStatement.java:500)”
“com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75)”
“–> driver.sql_jdbc.execute$fn__80988.invokeStatic(execute.clj:560)”
“driver.sql_jdbc.execute$fn__80988.invoke(execute.clj:558)”
“driver.sql_jdbc.execute$execute_statement_or_prepared_statement_BANG_.invokeStatic(execute.clj:568)”
“driver.sql_jdbc.execute$execute_statement_or_prepared_statement_BANG_.invoke(execute.clj:565)”
“driver.sql_jdbc.execute$execute_reducible_query$fn__81069$fn__81070.invoke(execute.clj:696)”
“driver.sql_jdbc.execute$execute_reducible_query$fn__81069.invoke(execute.clj:695)”
“driver.sql_jdbc.execute$fn__80864$fn__80865.invoke(execute.clj:388)”
“driver.sql_jdbc.execute$fn__80829$AMPERSAND_f__80830.invoke(execute.clj:334)"
“driver.sql_jdbc.execute$fn__80829$fn__80833.invoke(execute.clj:317)”
“driver.sql_jdbc.execute$fn__80864.invokeStatic(execute.clj:382)”
“driver.sql_jdbc.execute$fn__80864.invoke(execute.clj:380)”
“driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:689)”
“driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)”
“driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:686)”
“driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)”
“driver.sql_jdbc$fn__109934.invokeStatic(sql_jdbc.clj:82)”
“driver.sql_jdbc$fn__109934.invoke(sql_jdbc.clj:80)”
“query_processor.context$executef.invokeStatic(context.clj:60)”
“query_processor.context$executef.invoke(context.clj:49)”
“query_processor.context.default$default_runf.invokeStatic(default.clj:44)”
“query_processor.context.default$default_runf.invoke(default.clj:42)”
“query_processor.context$runf.invokeStatic(context.clj:46)”
“query_processor.context$runf.invoke(context.clj:40)”
“query_processor.reducible$identity_qp.invokeStatic(reducible.clj:39)”
“query_processor.reducible$identity_qp.invoke(reducible.clj:36)”
“query_processor.middleware.cache$maybe_return_cached_results$maybe_return_cached_results_STAR___73853.invoke(cache.clj:229)”
“query_processor.middleware.permissions$check_query_permissions$fn__67558.invoke(permissions.clj:140)”
“query_processor.middleware.enterprise$check_download_permissions_middleware$fn__73664.invoke(enterprise.clj:51)”
“query_processor.middleware.enterprise$maybe_apply_column_level_perms_check_middleware$fn__73674.invoke(enterprise.clj:64)”
“query_processor.middleware.mbql_to_native$mbql__GT_native$fn__72816.invoke(mbql_to_native.clj:24)”
“query_processor$fn__75056$combined_post_process__75061$combined_post_process_STAR___75062.invoke(query_processor.clj:261)”
“query_processor$fn__75056$combined_pre_process__75057$combined_pre_process_STAR___75058.invoke(query_processor.clj:258)”
“query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__67685.invoke(fetch_source_query.clj:303)”
“query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__73764$fn__73768.invoke(resolve_database_and_driver.clj:77)”
“driver$do_with_driver.invokeStatic(driver.clj:94)”
“driver$do_with_driver.invoke(driver.clj:89)”
“query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__73764.invoke(resolve_database_and_driver.clj:76)”
“query_processor.middleware.store$initialize_store$fn__68102$fn__68103.invoke(store.clj:14)”
“query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:169)”
“query_processor.store$do_with_metadata_provider.invoke(store.clj:150)”
“query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:158)”
“query_processor.store$do_with_metadata_provider.invoke(store.clj:150)”
“query_processor.middleware.store$initialize_store$fn__68102.invoke(store.clj:13)”
“query_processor.middleware.resolve_database_and_driver$resolve_database$fn__73761.invoke(resolve_database_and_driver.clj:60)”
“query_processor.middleware.normalize_query$normalize$fn__74071.invoke(normalize_query.clj:38)”
“query_processor.middleware.enterprise$fn__73691$handle_audit_app_internal_queries__73692$fn__73694.invoke(enterprise.clj:96)”
“query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__73702.invoke(enterprise.clj:103)”
“query_processor.middleware.constraints$add_default_userland_constraints$fn__70675.invoke(constraints.clj:81)”
“query_processor.middleware.process_userland_query$process_userland_query$fn__74002.invoke(process_userland_query.clj:156)”
“query_processor.middleware.catch_exceptions$catch_exceptions$fn__74600.invoke(catch_exceptions.clj:171)”
“query_processor.reducible$async_qp$qp_STAR___62532$thunk__62534.invoke(reducible.clj:126)”
“query_processor.reducible$async_qp$qp_STAR___62532$fn__62536.invoke(reducible.clj:131)”],
:state “08000”}
{:status :failed,
:class org.mariadb.jdbc.internal.util.exceptions.MariaDbSqlException,
:error “unexpected end of stream, read 0 bytes from 7 (socket was closed by server)”,
:stacktrace
[“org.mariadb.jdbc.internal.util.exceptions.MariaDbSqlException.of(MariaDbSqlException.java:34)”
“org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.exceptionWithQuery(AbstractQueryProtocol.java:195)”
“org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:263)”
“org.mariadb.jdbc.MariaDbStatement.executeInternal(MariaDbStatement.java:356)”
“org.mariadb.jdbc.MariaDbStatement.execute(MariaDbStatement.java:500)”
“com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75)”
“–> driver.sql_jdbc.execute$fn__80988.invokeStatic(execute.clj:560)”
“driver.sql_jdbc.execute$fn__80988.invoke(execute.clj:558)”
"driver.sql_jdbc.execute$execute_statement_or_prepared_statement_BANG
.invokeStatic(execute.clj:568)”
“driver.sql_jdbc.execute$execute_statement_or_prepared_statement_BANG_.invoke(execute.clj:565)”
“driver.sql_jdbc.execute$execute_reducible_query$fn__81069$fn__81070.invoke(execute.clj:696)”
“driver.sql_jdbc.execute$execute_reducible_query$fn__81069.invoke(execute.clj:695)”
“driver.sql_jdbc.execute$fn__80864$fn__80865.invoke(execute.clj:388)”
“driver.sql_jdbc.execute$fn__80829$AMPERSAND_f__80830.invoke(execute.clj:334)"
“driver.sql_jdbc.execute$fn__80829$fn__80833.invoke(execute.clj:317)”
“driver.sql_jdbc.execute$fn__80864.invokeStatic(execute.clj:382)”
“driver.sql_jdbc.execute$fn__80864.invoke(execute.clj:380)”
“driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:689)”
“driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)”
“driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:686)”
“driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)”
“driver.sql_jdbc$fn__109934.invokeStatic(sql_jdbc.clj:82)”
“driver.sql_jdbc$fn__109934.invoke(sql_jdbc.clj:80)”
“query_processor.context$executef.invokeStatic(context.clj:60)”
“query_processor.context$executef.invoke(context.clj:49)”
“query_processor.context.default$default_runf.invokeStatic(default.clj:44)”
“query_processor.context.default$default_runf.invoke(default.clj:42)”
“query_processor.context$runf.invokeStatic(context.clj:46)”
“query_processor.context$runf.invoke(context.clj:40)”
“query_processor.reducible$identity_qp.invokeStatic(reducible.clj:39)”
“query_processor.reducible$identity_qp.invoke(reducible.clj:36)”
“query_processor.middleware.cache$maybe_return_cached_results$maybe_return_cached_results_STAR___73853.invoke(cache.clj:229)”
“query_processor.middleware.permissions$check_query_permissions$fn__67558.invoke(permissions.clj:140)”
“query_processor.middleware.enterprise$check_download_permissions_middleware$fn__73664.invoke(enterprise.clj:51)”
“query_processor.middleware.enterprise$maybe_apply_column_level_perms_check_middleware$fn__73674.invoke(enterprise.clj:64)”
“query_processor.middleware.mbql_to_native$mbql__GT_native$fn__72816.invoke(mbql_to_native.clj:24)”
“query_processor$fn__75056$combined_post_process__75061$combined_post_process_STAR___75062.invoke(query_processor.clj:261)”
“query_processor$fn__75056$combined_pre_process__75057$combined_pre_process_STAR___75058.invoke(query_processor.clj:258)”
“query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__67685.invoke(fetch_source_query.clj:303)”
“query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__73764$fn__73768.invoke(resolve_database_and_driver.clj:77)”
“driver$do_with_driver.invokeStatic(driver.clj:94)”
“driver$do_with_driver.invoke(driver.clj:89)”
“query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__73764.invoke(resolve_database_and_driver.clj:76)”
“query_processor.middleware.store$initialize_store$fn__68102$fn__68103.invoke(store.clj:14)”
“query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:169)”
“query_processor.store$do_with_metadata_provider.invoke(store.clj:150)”
“query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:158)”
“query_processor.store$do_with_metadata_provider.invoke(store.clj:150)”
“query_processor.middleware.store$initialize_store$fn__68102.invoke(store.clj:13)”
“query_processor.middleware.resolve_database_and_driver$resolve_database$fn__73761.invoke(resolve_database_and_driver.clj:60)”
“query_processor.middleware.normalize_query$normalize$fn__74071.invoke(normalize_query.clj:38)”
“query_processor.middleware.enterprise$fn__73691$handle_audit_app_internal_queries__73692$fn__73694.invoke(enterprise.clj:96)”
“query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__73702.invoke(enterprise.clj:103)”
“query_processor.middleware.constraints$add_default_userland_constraints$fn__70675.invoke(constraints.clj:81)”
“query_processor.middleware.process_userland_query$process_userland_query$fn__74002.invoke(process_userland_query.clj:156)”
“query_processor.middleware.catch_exceptions$catch_exceptions$fn__74600.invoke(catch_exceptions.clj:171)”
“query_processor.reducible$async_qp$qp_STAR___62532$thunk__62534.invoke(reducible.clj:126)”
“query_processor.reducible$async_qp$qp_STAR___62532$fn__62536.invoke(reducible.clj:131)”],
:state “08000”}
{:status :failed,
:class java.sql.SQLNonTransientConnectionException,
:error “(conn=715130446) unexpected end of stream, read 0 bytes from 7 (socket was closed by server)”,
:stacktrace
[“org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)”
“org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:158)”
“org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:262)”
“org.mariadb.jdbc.MariaDbStatement.executeInternal(MariaDbStatement.java:362)”
“org.mariadb.jdbc.MariaDbStatement.execute(MariaDbStatement.java:500)”
“com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:75)”
“–> driver.sql_jdbc.execute$fn__80988.invokeStatic(execute.clj:560)”
“driver.sql_jdbc.execute$fn__80988.invoke(execute.clj:558)”
"driver.sql_jdbc.execute$execute_statement_or_prepared_statement_BANG
.invokeStatic(execute.clj:568)”
“driver.sql_jdbc.execute$execute_statement_or_prepared_statement_BANG_.invoke(execute.clj:565)”
“driver.sql_jdbc.execute$execute_reducible_query$fn__81069$fn__81070.invoke(execute.clj:696)”
“driver.sql_jdbc.execute$execute_reducible_query$fn__81069.invoke(execute.clj:695)”
“driver.sql_jdbc.execute$fn__80864$fn__80865.invoke(execute.clj:388)”
“driver.sql_jdbc.execute$fn__80829$_AMPERSAND_f__80830.invoke(execute.clj:334)”
“driver.sql_jdbc.execute$fn__80829$fn__80833.invoke(execute.clj:317)”
“driver.sql_jdbc.execute$fn__80864.invokeStatic(execute.clj:382)”
“driver.sql_jdbc.execute$fn__80864.invoke(execute.clj:380)”
“driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:689)”
“driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)”
“driver.sql_jdbc.execute$execute_reducible_query.invokeStatic(execute.clj:686)”
“driver.sql_jdbc.execute$execute_reducible_query.invoke(execute.clj:678)”
“driver.sql_jdbc$fn__109934.invokeStatic(sql_jdbc.clj:82)”
“driver.sql_jdbc$fn__109934.invoke(sql_jdbc.clj:80)”
“query_processor.context$executef.invokeStatic(context.clj:60)”
“query_processor.context$executef.invoke(context.clj:49)”
“query_processor.context.default$default_runf.invokeStatic(default.clj:44)”
“query_processor.context.default$default_runf.invoke(default.clj:42)”
“query_processor.context$runf.invokeStatic(context.clj:46)”
“query_processor.context$runf.invoke(context.clj:40)”
"query_processor.re

| username: dba远航 | Original post link

This should be a version support issue.

| username: onlyacat | Original post link

It seems there is an issue with TiDB, I’ll go take a look.

| username: tidb菜鸟一只 | Original post link

Isn’t Metabase accessed through the JDBC package? It can connect to MySQL 8 but not TiDB 7.5?

| username: a398058068 | Original post link

There is the same problem.

| username: Hacker_CvvT6v40 | Original post link

Yes, it is connected through the JDBC package (maralDB jar package). However, version 7.5 is invalid and cannot be used. It was working fine before, and there were no issues with the program connection.

| username: Hacker_CvvT6v40 | Original post link

Thank you :pray:

| username: dba远航 | Original post link

Try changing the version.

| username: TIDB-Learner | Original post link

New year, new look.

| username: YangKeao | Original post link

This issue might be related to the support for connection compression. Metabase has compression enabled by default. One workaround is to configure Metabase to disable compression:

The specific problem with compression still needs to be looked into :man_facepalming:

| username: 有猫万事足 | Original post link

Handsome :+1::+1::+1:

Tested and works well.
TiDB v7.5.0
Metabase v0.46.6.4