Heroku/Play/BoneCp connection issues

蹲街弑〆低调 提交于 2019-11-28 11:25:37

Try with BoneCP 0.8.0-rc1 and use this configuration:

db.default.idleMaxAge=10 minutes
db.default.idleConnectionTestPeriod=30 seconds
db.default.connectionTimeout=20 second
db.default.connectionTestStatement="SELECT 1"
db.default.maxConnectionAge=30 minutes

There is a defect in how BoneCP/Heroku/Play deal with connections. I made a fix to BoneCP on github under:

https://github.com/wwadge/bonecp/pull/10

Also, the compiled library is available by adding the following to Build.scala:

val appDependencies = Seq(
"com.jolbox" % "bonecp" % "0.8.0-rc2-SNAPSHOT-20130712-14382677.jar",
....

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
  libraryDependencies += "com.jolbox" % "bonecp" % "0.8.0-rc2-SNAPSHOT-20130712-14382677.jar" from "https://dl.dropboxusercontent.com/u/36714110/libraries/bonecp-patches/bonecp-0.8.0-rc2-SNAPSHOT-20130712-14382677.jar"
,resolvers += ...

I had the same issue using a remote postgres instance. I added the following to my application.conf db setup:

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

That did the trick for me. I am using the org.postgresql.Driver driver.

There is a known issue with connection leaks for version 0.7.1 of BoneCP (which is currently the stable release) - Bug 999114. Switching to a later version as mentioned by @MaFo should fix it. There is also a workaround mentioned in BoneCP/Postgres connections leak

In the end I switched to another connection pool Tomcat JDBC Connection Pool on a project I was working on as I hope it is (will be) better supported as it part of the apache project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!