playframework 2.0 - 超过了数据库演变的 max_user_connections?
我想知道如何配置我的 play 2.0 应用程序,以便在数据库演进和运行时不使用这么多数据库连接.我在小组和 IRC 中都问过这个问题,但没有运气.
I am looing any insight as to how I can configure my play 2.0 app to not use so many database connections on both database evolutions and during runtime. I have asked this in the group and in IRC with no luck.
我正在使用带有 heroku 的 cleardb ignite 实例 (max_user_connections = 10)...
I am using cleardb ignite instance (max_user_connections = 10) with heroku...
基本上,当我尝试在我的 play 2.0 应用程序上运行数据库进化时,我得到:
Basically when I try to run database evolutions on my play 2.0 app I get:
! @6a2mjd7kg - Internal server error, for request [GET /] ->
play.api.db.evolutions.InvalidDatabaseRevision: Database 'default' needs evolution! [An SQL script need to be run on your database.]
at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:424) ~[play_2.9.1.jar:2.0]
at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:410) ~[play_2.9.1.jar:2.0]
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) ~[scala-library.jar:0.11.2]
at scala.collection.immutable.List.foreach(List.scala:45) ~[scala-library.jar:0.11.2]
at play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:410) ~[play_2.9.1.jar:2.0]
at play.api.Play$$anonfun$start$1.apply(Play.scala:60) ~[play_2.9.1.jar:2.0]
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 10. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 9. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 8. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 7. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 6. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 5. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 4. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 3. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 2. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 1. Exception: null
[error] application -
! Internal server error, for request [GET /@evolutions/apply/default?redirect=http%3A%2F%2Flocalhost%3A9000%2F] ->
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User '52841e548f150d' has exceeded the 'max_user_connections' resource (current value: 10)
at sun.reflect.GeneratedConstructorAccessor26.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl. java:27) ~[na:1.6.0_29]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_29]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java- 5.1.18.jar:na]
at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) ~[mysql-connector-java-5.1.18.jar:na]
然后我也经常会得到通常的Exceeded max_user_connections",这种情况在不进行进化时也经常发生.
Then also I often will get the usual "Exceeded max_user_connections', this happens very frequently when not doing evolutions also.
我也可以收到此错误消息:
I can also get this error message:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User '52841e548f150d' has exceeded the 'max_user_connections' resource (current value: 10)
at sun.reflect.GeneratedConstructorAccessor19.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_29]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_29]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.18.jar:na]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) ~[mysql-connector-java-5.1.18.jar:na]
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 10. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 9. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 8. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 7. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 6. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 5. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 4. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 3. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 2. Exception: null
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 1. Exception: null
[error] application -
我的 application.conf 看起来像这样,我尝试了很多变体...
My application.conf looks like this, and I have tried many variations...
db.default=mysql
db.default.driver=com.mysql.jdbc.Driver
db.default.url="mysql://usr:pass@db_url.com/db_name"
db.default.minSize=1
db.default.maxSize=2
在这一点上,任何指导、建议、链接都会非常有帮助......
Any guidance, suggessions, links, would be extremely helpful at this point...
推荐答案
更新答案.
这是一个仅使用 5 个连接的配置.
Here is a configuration that only uses 5 connections.
db.default.partitionCount=1
db.default.maxConnectionsPerPartition=5
db.default.minConnectionsPerPartition=5
# Connections 将为 partitionCount x ConnectionsPerPartition
# Connections will be partitionCount x ConnectionsPerPartition
相关文章