Closed VikramTiwari closed 3 years ago
does this go away on a restart?
this sounds like an issue connecting with the application database
Should have provided more details. This doesn't happen during start, it just happens randomly. It also auto fixes itself. I haven't looked into it since but I will add more details this weekend if I see it still happening.
Same thing happened with me as well. Suddenly it threw Connections could not be acquired from the underlying database!
I'm running Metabase on a linux server with a Docker Container.
Could you guys just be experiencing fallacy number 1. in https://www.infoworld.com/article/3114195/system-management/the-8-fallacies-of-distributed-computing-are-becoming-irrelevant.html ⬅️ (But they’re not gone in all environments)
;) Yes I know, a bit cheeky response, apologies! To try to be constructive:
Same problem here. What can I do about it?
I am running 0.25.1
here, against a PostgreSQL RDS instance.
Oct 19 11:39:37 18.207.193.200 metabase: :cause A ResourcePool could not acquire a resource from its primary factory or source.
Oct 19 11:39:37 18.207.193.200 metabase: :via
Oct 19 11:39:37 18.207.193.200 metabase: [{:type java.sql.SQLException
Oct 19 11:39:37 18.207.193.200 metabase: :message Connections could not be acquired from the underlying database!
Oct 19 11:39:37 18.207.193.200 metabase: :at [com.mchange.v2.sql.SqlUtils toSQLException SqlUtils.java 118]}
Oct 19 11:39:37 18.207.193.200 metabase: {:type com.mchange.v2.resourcepool.CannotAcquireResourceException
Oct 19 11:39:37 18.207.193.200 metabase: :message A ResourcePool could not acquire a resource from its primary factory or source.
Oct 19 11:39:37 18.207.193.200 metabase: :at [com.mchange.v2.resourcepool.BasicResourcePool awaitAvailable BasicResourcePool.java 1319]}]
Oct 19 11:39:37 18.207.193.200 metabase: :trace
Oct 19 11:39:37 18.207.193.200 metabase: [[com.mchange.v2.resourcepool.BasicResourcePool awaitAvailable BasicResourcePool.java 1319]
Oct 19 11:39:37 18.207.193.200 metabase: [com.mchange.v2.resourcepool.BasicResourcePool prelimCheckoutResource BasicResourcePool.java 557]
Oct 19 11:39:37 18.207.193.200 metabase: [com.mchange.v2.resourcepool.BasicResourcePool checkoutResource BasicResourcePool.java 477]
Oct 19 11:39:37 18.207.193.200 metabase: [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool checkoutPooledConnection C3P0PooledConnectionPool.java 525]
Oct 19 11:39:37 18.207.193.200 metabase: [com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getConnection AbstractPoolBackedDataSource.java 128]
Oct 19 11:39:37 18.207.193.200 metabase: [clojure.java.jdbc$get_connection invokeStatic jdbc.clj 298]
Oct 19 11:39:37 18.207.193.200 metabase: [clojure.java.jdbc$get_connection invoke jdbc.clj 193]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.driver.generic_sql$describe_database invokeStatic generic_sql.clj 412]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.driver.generic_sql$describe_database invoke generic_sql.clj 409]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.driver$fn__22486$G__22452__22493 invoke driver.clj 45]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database.introspect$db__GT_tables invokeStatic introspect.clj 188]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database.introspect$db__GT_tables invoke introspect.clj 187]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database.introspect$introspect_database_and_update_raw_tables_BANG_ invokeStatic introspect.clj 204]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database.introspect$introspect_database_and_update_raw_tables_BANG_ invoke introspect.clj 198]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database$sync_database_with_tracking_BANG_$fn__30875 invoke sync_database.clj 78]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database$sync_database_with_tracking_BANG_ invokeStatic sync_database.clj 75]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database$sync_database_with_tracking_BANG_ invoke sync_database.clj 69]
Oct 19 11:39:37 18.207.193.200 metabase: [clojure.core$partial$fn__4763 invoke core.clj 2528]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.driver$fn__22710 invokeStatic driver.clj 252]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.driver$fn__22710 invoke driver.clj 252]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.driver$fn__22659$G__22442__22668 invoke driver.clj 45]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database$sync_database_BANG_ invokeStatic sync_database.clj 44]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.sync_database$sync_database_BANG_ doInvoke sync_database.clj 25]
Oct 19 11:39:37 18.207.193.200 metabase: [clojure.lang.RestFn invoke RestFn.java 410]
Oct 19 11:39:37 18.207.193.200 metabase: [metabase.events.sync_database$process_sync_database_event$fn__45970 invoke sync_database.clj 31]
Oct 19 11:39:37 18.207.193.200 metabase: [clojure.core$binding_conveyor_fn$fn__4676 invoke core.clj 1938]
Oct 19 11:39:37 18.207.193.200 metabase: [clojure.lang.AFn call AFn.java 18]
Oct 19 11:39:37 18.207.193.200 metabase: [java.util.concurrent.FutureTask run FutureTask.java 266]
Oct 19 11:39:37 18.207.193.200 metabase: [java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1142]
Oct 19 11:39:37 18.207.193.200 metabase: [java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 617]
Oct 19 11:39:37 18.207.193.200 metabase: [java.lang.Thread run Thread.java 745]]}
Still an issue with v0.31.0-snapshot
SQLException:
Message: Connections could not be acquired from the underlying database!
SQLState: null
Error Code: 0
03-06 11:56:32 ERROR generic-sql.query-processor :: nil
Hi @viluon Try 0.31.2 - and which database are you using for Metabase internal? Do you see anything on the log of your database? Have you tried to follow the troubleshooting guide? https://metabase.com/docs/latest/troubleshooting-guide/datawarehouse.html
Hi @flamber. I'm now on v0.31.3
and the issue is still present. I'll get back to you as soon as I determine which database connection is the problematic one, there are quite a few DBs connected to this Metabase instance. The weirdest thing is the lack of a stack trace or other detailed listing of the error, despite a DEBUG log level:
03-06 18:19:31 DEBUG metabase.middleware :: POST /api/card/6/query 200 (86 ms) (10 DB calls). Jetty threads: 8/50 (4 busy, 6 idle, 0 queued)
SQLException:
Message: Connections could not be acquired from the underlying database!
SQLState: null
Error Code: 0
03-06 18:19:34 ERROR generic-sql.query-processor :: nil
03-06 18:19:39 INFO api.card :: Card results metadata passed in to API is VALID. Thanks!
03-06 18:19:39 DEBUG metabase.middleware :: PUT /api/card/6 200 (14 ms) (10 DB calls). Jetty threads: 8/50 (4 busy, 6 idle, 0 queued)
I'm not aware of any configuration changes which could cause this behaviour.
@viluon I'm not talking about datasources - I was asking what database you use for Metabase's internal structure. It's H2 by default, which is not recommended for production use. You should be using Postgres or MySQL/MariaDB for the internal database. If you're using non-H2, then you should be able to see failed connections or queries on your database log.
@flamber Ah, I see, no, the instance uses PostgreSQL. EDIT: it seems that the issue either isn't with the Metabase database (on PostgreSQL) or that Metabase can't connect at all, there are no mentions of connections to the MB database in the server log (it is set to warning+ level). It is important to note that one can log into this Metabase instance, therefore the connection to the underlying DB is at least partially working.
@viluon
Is Metabase and Postgres on the same server - otherwise it could be blocked by some firewall or DoS protection, or simply just a bad connection between the two. You could use tcpdump
to see all the network activity between the two.
@flamber it's definitely not that. Not only did it work before and the firewall would have to somehow be picky about which packets to let through and which ones to block (since logging in, viewing questions, dashboards, etc. works normally), there have been no changes to the network configuration that could cause this behaviour and, above all, they are both on the same server.
@flamber just got a word from a user of the instance, the weird behaviour started after adding a connection to a MySQL database. By weird behaviour I mean the errors, but also complete blackouts of the instance, where after a couple of these errors the server just stopped responding entirely, the logs went black, and the instance had to be restarted to work again. This was on the aforementioned v0.31.0-snapshot
however, it is possible that the changes introduced by upgrading to v0.31.3
fixed these crashes.
happening here on v0.32.8. Just upgraded and now getting this error from the web version. I'm using Metabase from Mac to make queries to an Amazon RDS (I can connect via mysqlpro without issues)
@viluon upgrading to 0.32.8 will fix you server hanging issues. In older versions queries that were waiting for connections could exhaust all available threads and the server would be unable to handle new requests.
I have updated Metabase from 0.30.4
to 0.32.8
and got this issue, using MySQL.
had this issue yesterday when upgrading from 0.30.* to 0.32.8 and fixed it by adding
trustServerCertificate=true
to Additional JDBC connection string options: for the database.
had this issue yesterday when upgrading from 0.30.* to 0.32.8 and fixed it by adding
trustServerCertificate=true
to Additional JDBC connection string options: for the database.
It works, thank you!
Try to check the connection from metabase server(docker: using cmd docker inspect --format '{{ .NetworkSettings.IPAddress }}' <your_docker_container>
) to your database application server(including with application port, e.g 3306, 5432...). Sometime the issue just because the firewall block the connection from another.
had this issue yesterday when upgrading from 0.30.* to 0.32.8 and fixed it by adding
trustServerCertificate=true
to Additional JDBC connection string options: for the database.
I added this option - It works! Then I removed this option - I works again! I think any change of jdbc options reset connection and can help to resolve this problem. But manual actions are required always.
This was fixed by #11771 -- the issue was we didn't check whether existing Connections were still valid before using them, so after a while the connection pool could get filled with invalid connections.
Metabase version: 0.28.6
Metabase hosting environment: Docker on Debian GNU/Linux 8.10
Metabase internal database: MySQL
Repeatable steps to reproduce the issue Not sure how this happened but I see 100s of these errors within a few seconds. Any idea what might be causing this? The server was not under any external load.