2012-04-11 115 views
6

我对我如何配置我的play 2.0应用程序没有在数据库演变和运行时使用如此多的数据库连接有所了解。我在小组和IRC中都问过这个问题,但没有运气。playframework 2.0 - 数据库演变超过max_user_connections?

我使用cleardb点燃实例(MAX_USER_CONNECTIONS = 10)的Heroku ...

基本上当我尝试对我的打法运行数据库变阵2.0应用程序,我得到:

! @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] 

然后还我往往会得到一贯的“超出MAX_USER_CONNECTIONS',这种情况非常频繁不做变阵时也

我也可以得到这样的错误信息:

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看起来是这样的,我已经尝试了许多变化...

db.default=mysql 
db.default.driver=com.mysql.jdbc.Driver 
db.default.url="mysql://usr:[email protected]_url.com/db_name" 
db.default.minSize=1 
db.default.maxSize=2 

任何指导,suggessions,链接,会在这一点上非常有帮助...

+0

我有同样的问题。望着它... – 2012-04-12 03:42:36

+0

我能够对本地mysql数据库做一个简单的应用程序工作,但无法使它对抗ClearDB。你能提交Heroku支持请求吗?这里是我的测试项目: https://github.com/jamesward/play2bars-java/tree/mysql – 2012-04-12 04:05:43

回答

6

更新回答。

这是一个只使用5个连接的配置。

db.default.partitionCount=1 
db.default.maxConnectionsPerPartition=5 
db.default.minConnectionsPerPartition=5 

#连接将被partitionCount x ConnectionsPerPartition

+0

你能用Heroku提出支持请求吗? – 2012-04-24 18:37:34

+0

@JamesWard我不太确定它是heroku/clearDb但是你启动服务器启动与运行我会更新我的答案。 – Farmor 2012-04-25 07:08:34

+0

这帮了我。在我的Postgres数据库本地运行测试时,我不一致地发现连接异常。 – duma 2012-11-11 17:57:30