我正在运行Play 2.2.0应用程序,使用Postgres 9.2-1002-jdbc4和Anorm 2.2.0 API。我经常遇到连接问题:
2013-11-19 19:45:36,544 [ERROR][a.d.Dispatcher][play-akka.actor.default-dispatcher-17] This connection has been closed.org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:822) ~[org.postgresql.postgresql-9.2-1002-jdbc4.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Connection.setAutoCommit(AbstractJdbc2Connection.java:769) ~[org.postgresql.postgresql-9.2-1002-jdbc4.jar:na]
at com.jolbox.bonecp.ConnectionHandle.setAutoCommit(ConnectionHandle.java:1247) ~[com.jolbox.bonecp-0.8.0-rc1.jar:na]
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:251) ~[com.jolbox.bonecp-0.8.0-rc1.jar:na]
at com.jolbox.bonecp.ConnectionHandle.recreateConnectionHandle(ConnectionHandle.java:273) ~[com.jolbox.bonecp-0.8.0-rc1.jar:na]
at com.jolbox.bonecp.ConnectionHandle.close(ConnectionHandle.java:476) ~[com.jolbox.bonecp-0.8.0-rc1.jar:na]
at play.api.db.AutoCleanConnection.close(DB.scala:485) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at play.api.db.DBApi$class.withConnection(DB.scala:84) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at play.api.db.BoneCPApi.withConnection(DB.scala:276) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at play.api.db.DBApi$class.withTransaction(DB.scala:97) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at play.api.db.BoneCPApi.withTransaction(DB.scala:276) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at play.api.db.DB$$anonfun$withTransaction$4.apply(DB.scala:185) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at play.api.db.DB$$anonfun$withTransaction$4.apply(DB.scala:185) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
at scala.Option.map(Option.scala:145) ~[org.scala-lang.scala-library-2.10.2.jar:na]
at play.api.db.DB$.withTransaction(DB.scala:185) ~[com.typesafe.play.play-jdbc_2.10-2.2.0.jar:2.2.0]
我知道没有数据库连接问题;数据库运行在同一个盒子上。这些连接问题每天间歇性地发生2-3次,并且可以自行恢复。
我尝试了这些荒谬的低连接测试设置:
db.default.idleConnectionTestPeriod=10 seconds
db.default.idleMaxAge=30 seconds
db.default.maxConnectionAge=60 seconds
这些连接设置似乎可以减少它,虽然我想知道是否有更基本的事情发生。 postgres日志中没有任何内容。
答案 0 :(得分:1)
有一个关于BoneCP(实际上是其中一些)的错误,已经在Play 2.2.3中得到修复:https://github.com/playframework/playframework/pull/1898