Unable to init Metabase in Cloud SQL

I'm trying to run Metabase on Cloud Run with Cloud SQL MySQL but when I push my service in Cloud Run the metabase database isn't initialized. The service running correctly I can access to the URL but the data are empty. But it's weird because Metabase create me 2 tables in the Database.

mysql> show tables;
+-----------------------+
| Tables_in_metabase    |
+-----------------------+
| DATABASECHANGELOG     |
| DATABASECHANGELOGLOCK |
+-----------------------+

One is empty and the other table got this:

+----+----------------+-------------+----------+
| ID | LOCKED         | LOCKGRANTED | LOCKEDBY |
+----+----------------+-------------+----------+
|  1 | 0x00           | NULL        | NULL     |
+----+----------------+-------------+----------+

Here is my Dockerfile:

FROM metabase/metabase

ENV MB_DB_TYPE mysql
ENV MB_DB_DBNAME metabase
ENV MB_DB_PORT 3306
ENV MB_DB_USER root
ENV MB_DB_PASS mypass
ENV MB_DB_HOST my_public_ip
ENV METABASE_SQL_INSTANCE my_instance_name:tcp=3306

In the logs I can see this message:
INFO plugins.dependencies :: e[31mMetabase cannot initialize plugin Metabase Vertica Driver due to required dependencies.e[0m 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.

And many rows like this :
Container Sandbox: Unsupported syscall UNKNOWN[439/0x1b7](0xffffffffffffff9c,0x3e695eddeb00,0x1,0x200,0x200,0x3e695eddeb00). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/docs/user_guide/compatibility/linux/amd64/UNKNOWN[439/0x1b7] for more information.

My other services running in Cloud Run can access to Cloud SQL without problem by using UNIX Socket but with the metabase service I don't know why it doesn't work. I don't use proxy cloud because my service is in the same project than the Cloud SQL instance.

I can see in the logs Metabase is shutting down

2022-03-11T12:03:46.253520Z

2022-03-11 12:03:46,253 INFO plugins.dependencies :: Metabase Vertica Driver dependency {:class com.vertica.jdbc.Driver} satisfied? false

2022-03-11T12:03:46.254049Z

2022-03-11 12:03:46,253 INFO plugins.dependencies :: e[33mPlugins with unsatisfied deps: ["Metabase Oracle Driver" "Metabase Vertica Driver"]e[0m

2022-03-11T12:03:46.254324Z

2022-03-11 12:03:46,254 INFO metabase.core :: Setting up and migrating Metabase DB. Please sit tight, this may take a minute...

2022-03-11T12:03:46.258288Z

2022-03-11 12:03:46,257 INFO db.setup :: e[36mVerifying mysql Database Connection ...e[0m

2022-03-11T12:03:47.182216Z

GET5031,62 Ko6 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

2022-03-11T12:03:47.325811Z

2022-03-11 12:03:47,325 INFO db.setup :: Successfully verified MySQL 5.7.36-google application database connection. ✅

2022-03-11T12:03:47.330113Z

2022-03-11 12:03:47,329 INFO db.setup :: Running Database Migrations...

2022-03-11T12:03:48.176763Z

GET5031,62 Ko5 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

2022-03-11T12:03:48.197788Z

2022-03-11 12:03:48,197 INFO db.setup :: Setting up Liquibase...

2022-03-11T12:03:48.222906Z

2022-03-11 12:03:48,222 INFO db.setup :: Liquibase is ready.

2022-03-11T12:03:48.223359Z

2022-03-11 12:03:48,223 INFO db.liquibase :: Checking if Database has unrun migrations...

2022-03-11T12:03:49.180371Z

GET5031,62 Ko6 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

2022-03-11T12:03:50.169448Z

GET5031,62 Ko8 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

2022-03-11T12:03:51.168973Z

GET5031,62 Ko7 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

2022-03-11T12:03:52.175088Z

GET5031,62 Ko6 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health



2022-03-11T12:03:53.171036Z

GET5031,62 Ko7 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health


2022-03-11T12:03:54.174932Z

GET5031,62 Ko5 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health


2022-03-11T12:03:55.182729Z

GET5031,62 Ko8 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

GET5031,62 Ko7 msChrome 98 https://metabase-bcsxqdqetq-ew.a.run.app/api/health

2022-03-11 12:03:56,170 INFO metabase.core :: Metabase Shutting Down ...


2022-03-11T12:03:56.181639Z

2022-03-11 12:03:56,181 INFO metabase.server :: Shutting Down Embedded Jetty Webserver

Do you have an idea to help me please ?

Hi @JohnLT
Make sure that the container isn't shutdown before it has finished the setup.
Have a look here: Has anyone deployed Metabase to Google Cloud Run?

Hello thank you for your reply. Yeah I tried lot of things that I see on this forum or stackoverflow but I don't know what is wrong :/. I'm using the default metabase image.
If my container is shutdown before how can I keep it up ?

@JohnLT I don't know Cloud Run, so use another service if you cannot get it to work.

I tried to init a default metabase database, then I import this database in Cloud SQL. I run metabase Cloud RUN service and I used the generated database and it works.

But when I init metabase from the start I got 25 tables created :

+-------------------------------+
| Tables_in_metac               |
+-------------------------------+
| DATABASECHANGELOG             |
| DATABASECHANGELOGLOCK         |
| annotation_annotation         |
| core_organization             |
| core_permissionsviolation     |
| core_session                  |
| core_user                     |
| core_userorgperm              |
| metabase_database             |
| metabase_field                |
| metabase_fieldvalues          |
| metabase_foreignkey           |
| metabase_table                |
| metabase_tablesegment         |
| query_query                   |
| query_queryexecution          |
| report_card                   |
| report_cardfavorite           |
| report_dashboard              |
| report_dashboardcard          |
| report_dashboardsubscription  |
| report_emailreport            |
| report_emailreport_recipients |
| report_emailreportexecutions  |
| setting                       |
+-------------------------------+

And I got this stack trace:
liquibase.exception.LockException: Database has migration lock; cannot run migrations. You can force-release these locks by runningjava -jar metabase.jar migrate release-locks. at metabase.db.liquibase$wait_for_migration_lock_to_be_cleared$fn__14364.invoke(liquibase.clj:109) at metabase.util$do_with_auto_retries.invokeStatic(util.clj:471) at metabase.util$do_with_auto_retries.invoke(util.clj:463) at metabase.util$do_with_auto_retries.invokeStatic(util.clj:478) at metabase.util$do_with_auto_retries.invoke(util.clj:463) at metabase.util$do_with_auto_retries.invokeStatic(util.clj:478) at metabase.util$do_with_auto_retries.invoke(util.clj:463) at metabase.util$do_with_auto_retries.invokeStatic(util.clj:478) at metabase.util$do_with_auto_retries.invoke(util.clj:463) at metabase.util$do_with_auto_retries.invokeStatic(util.clj:478) at metabase.util$do_with_auto_retries.invoke(util.clj:463) at metabase.util$do_with_auto_retries.invokeStatic(util.clj:478) at metabase.util$do_with_auto_retries.invoke(util.clj:463) at metabase.db.liquibase$wait_for_migration_lock_to_be_cleared.invokeStatic(liquibase.clj:104) at metabase.db.liquibase$wait_for_migration_lock_to_be_cleared.invoke(liquibase.clj:100) at metabase.db.liquibase$migrate_up_if_needed_BANG_.invokeStatic(liquibase.clj:120) at metabase.db.liquibase$migrate_up_if_needed_BANG_.invoke(liquibase.clj:114) at metabase.db.setup$migrate_BANG_$fn__34014$fn__34015.invoke(setup.clj:68) at metabase.db.liquibase$do_with_liquibase.invokeStatic(liquibase.clj:38) at metabase.db.liquibase$do_with_liquibase.invoke(liquibase.clj:30) at metabase.db.setup$migrate_BANG_$fn__34014.invoke(setup.clj:63) at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:807) at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776) at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:852) at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776) at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:789) at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776) at metabase.db.setup$migrate_BANG_.invokeStatic(setup.clj:54) at metabase.db.setup$migrate_BANG_.invoke(setup.clj:40) at metabase.db.setup$run_schema_migrations_BANG_.invokeStatic(setup.clj:119) at metabase.db.setup$run_schema_migrations_BANG_.invoke(setup.clj:115) at metabase.db.setup$setup_db_BANG_$fn__34065$fn__34066.invoke(setup.clj:143) at metabase.util$do_with_us_locale.invokeStatic(util.clj:692) at metabase.util$do_with_us_locale.invoke(util.clj:678) at metabase.db.setup$setup_db_BANG_$fn__34065.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__34175.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:90) at metabase.core$init_BANG_.invoke(core.clj:73) at metabase.core$start_normally.invokeStatic(core.clj:131) at metabase.core$start_normally.invoke(core.clj:125) at metabase.core$_main.invokeStatic(core.clj:164) at metabase.core$_main.doInvoke(core.clj:158) 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)

@JohnLT I guess that Metabase doesn't work on Cloud Run. Use another type of service.

It works only if I setup manually the database. I'll try to make it run on App Engine too, but I don't understand why it doesn't work on Cloud Run. Cloud Run just run the container there is no difference between App Engine or local environnement because I just use a docker image.