RDS MySQL Aurora Issue + Solution

Was upgrading to v0.4x of metabase from v0.3x.x, a year overdue
The metabase admin DB is on an RDS Aurora mysql instance, and was testing locally before upgrading production and got the following error, it's truncated and not terribly useful.

2022-04-08 18:44:20,655 ERROR metabase.core :: Metabase Initialization FAILED
clojure.lang.ExceptionInfo: Unable to connect to Metabase mysql DB. {}
	at metabase.db.setup$fn__34042$verify_db_connection__34047$fn__34048$fn__34049.invoke(setup.clj:102)
	at metabase.db.setup$fn__34042$verify_db_connection__34047$fn__34048.invoke(setup.clj:100)
	at metabase.db.setup$fn__34042$verify_db_connection__34047.invoke(setup.clj:94)
	at metabase.db.setup$setup_db_BANG_$fn__34077$fn__34078.invoke(setup.clj:142)
	at metabase.util$do_with_us_locale.invokeStatic(util.clj:699)
	at metabase.util$do_with_us_locale.invoke(util.clj:685)
	at metabase.db.setup$setup_db_BANG_$fn__34077.invoke(setup.clj:141)
	at metabase.db.setup$setup_db_BANG_.invokeStatic(setup.clj:140)
	at metabase.db.setup$setup_db_BANG_.invoke(setup.clj:136)
	at metabase.db$setup_db_BANG_$fn__34187.invoke(db.clj:61)
	at metabase.db$setup_db_BANG_.invokeStatic(db.clj:56)
	at metabase.db$setup_db_BANG_.invoke(db.clj:51)
	at metabase.core$init_BANG_.invokeStatic(core.clj:91)
	at metabase.core$init_BANG_.invoke(core.clj:74)
	at metabase.core$start_normally.invokeStatic(core.clj:132)
	at metabase.core$start_normally.invoke(core.clj:126)
	at metabase.core$_main.invokeStatic(core.clj:165)
	at metabase.core$_main.doInvoke(core.clj:159)
	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.sql.SQLNonTransientConnectionException: Could not connect to address=(host=xxxxxxxxxxxxxxx.us-east-2.rds.amazonaws.com)(port=3306)(type=master) : (conn=6161845) could not load system variables
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:197)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1394)
	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:635)
	at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)
	at org.mariadb.jdbc.Driver.connect(Driver.java:89)
	at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
	at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
	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:1111)
	at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1093)
	at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1182)
	at clojure.java.jdbc$query.invoke(jdbc.clj:1144)
	at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1160)
	at clojure.java.jdbc$query.invoke(jdbc.clj:1144)
	at metabase.driver.sql_jdbc.connection$can_connect_with_spec_QMARK_.invokeStatic(connection.clj:245)
	at metabase.driver.sql_jdbc.connection$can_connect_with_spec_QMARK_.invoke(connection.clj:242)
	at metabase.db.setup$fn__34042$verify_db_connection__34047$fn__34048$fn__34049.invoke(setup.clj:100)
	... 21 more
Caused by: java.sql.SQLNonTransientConnectionException: (conn=6161845) could not load system variables
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:188)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.requestSessionDataWithShow(AbstractConnectProtocol.java:1114)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.readPipelineAdditionalData(AbstractConnectProtocol.java:1075)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.postConnectionQueries(AbstractConnectProtocol.java:885)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:600)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1389)
	... 39 more
Caused by: java.sql.SQLNonTransientConnectionException: (conn=6161845) Connection is closed
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:192)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.cmdPrologue(AbstractQueryProtocol.java:1946)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:249)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.requestSessionDataWithShow(AbstractConnectProtocol.java:1089)
	... 43 more
2022-04-08 18:44:20,700 INFO metabase.core :: Metabase Shutting Down ...
2022-04-08 18:44:20,703 INFO metabase.server :: Shutting Down Embedded Jetty Webserver
2022-04-08 18:44:20,728 INFO metabase.core :: Metabase Shutdown COMPLETE

After much googling found the following ticke
https://jira.mariadb.org/browse/CONJ-888
If you are using mysql-connector-j you "should" be ok the ODBCJ8 codebase has this issue

Aurora has a proxy that doesn't like pipelining (sending multiple mysql packet, then reading multiple packet).

Pipelining permits having better performance. Best then is to disable all pipelining capability (i.e. adding '&usePipelineAuth=false&useBatchMultiSend=false').
(MySQL driver doesn't use pipelining)

Solution:
Switch from using environment variable MB_DB_HOST to using MB_DB_CONNECTION_URI to use connection parameters in your connection string.

And use &trustServerCertificate=true&usePipelineAuth=false&useBatchMultiSend=false

MB_DB_CONNECTION_URI=jdbc:mysql://HOSTNAME/DB_NAME?user=USER_NAME&password=PASSWORD&trustServerCertificate=true&usePipelineAuth=false&useBatchMultiSend=false

Solved the problem for me

3 Likes

Hi @pjaol
I saw issue 888, when we decided to upgrade the driver (0.42.3) to fix several other problems that a lot of people were hitting, but it seemed like it had an easy workaround, which is why I went ahead with it.
You're the first person to encounter this problem as far as I know.
Thank you for posting the solution.

Might be worthwhile updating https://www.metabase.com/docs/latest/administration-guide/databases/oracle.html

Even with a link to this or adding a paragraph to the troubleshooting section.

Metabase has some excellent new features that I'm looking forward to deploying.

@pjaol I'm unsure why you're linking to the Oracle driver, when this is about MySQL/MariaDB.
But yes, it should be part of the troubleshooting guide if we cannot figure a way to detect Aurora and provide a better error message. I'm still trying to figure out if other hosted databases might be affected.

Thanks for the solution, you saved me a lot o time!