2

There is just one place in my app, that uses connections.
It looks something like this:

Connection conn = Db.getConnection();
try
{
    // do some job
}
finally
{
    conn.close();
}

So, connection is always closed.
But after some time i always get much more connections than defined in bonecp config ...

Question:
Is there clear solution for that problem?
May be i should try play framework 2.1?

I really can't get how some people use that framework without problems...

Configuration:

db.default.autocommit=true
db.default.isolation=READ_COMMITTED

db.default.partitionCount=3
db.default.minConnectionsPerPartition=6
db.default.maxConnectionsPerPartition=12
db.default.acquireIncrement=1

db.default.acquireRetryAttempts=5
db.default.acquireRetryDelay=50 milliseconds

db.default.connectionTimeout=50 milliseconds
db.default.idleMaxAge=3 minutes

db.default.idleConnectionTestPeriod=0
db.default.initSQL="SELECT 1"

db.default.logStatements=true
db.default.maxConnectionAge=10 minutes

db.default.releaseHelperThreads=0

Thanks!

Oleg Golovanov
  • 905
  • 1
  • 14
  • 24

4 Answers4

1

Also look at the poolThreshold parameter. By default this is set at 20% of all connections (in versions < 0.8, I defaulted it to zero from 0.8 and above because it surprises plenty of people).

Wallace

wwadge
  • 3,506
  • 1
  • 19
  • 28
  • Thanks for advice, but it does not help. I configured boneCP to use at max 24 connections, but after 10 hours it used all 50 available ... – Oleg Golovanov Dec 13 '12 at 09:56
  • What version of BoneCP are you using? The latest version is currently: 0.8.0-rc1 – wwadge Dec 17 '12 at 12:18
  • I am using play framework 2.0.4 that comes with BoneCP 0.7.1 :) Currently i solved my problem by restarting the server every several hours. Anyway, thanks! – Oleg Golovanov Dec 18 '12 at 17:32
0

My understanding is that conn.close() does not really close the connection. Instead it releases the connection back to the connection pool. The connection pool always tries to have minConnections, in your case 6 per partition, to the database.

This might be the reason why "always get much more connections", but this is they way it should work.

Franz
  • 1,993
  • 13
  • 20
  • Yes, conn.close() does not close the connection, but return it to pool. You did not get the problem: i configured boneCP to use at max N connections, but it uses more, than N. – Oleg Golovanov Dec 13 '12 at 09:55
0

try with BoneCP 0.8.0-rc1 and use this configuration:

db.default.idleMaxAge=10 minutes
db.default.idleConnectionTestPeriod=35 seconds
db.default.connectionTimeout=20 second
db.default.connectionTestStatement="SELECT 1"
db.default.maxConnectionAge=30 minutes
Marco
  • 1,494
  • 13
  • 23
0

I have been facing the same issue after deploying my website on Amazon.

Trial Solution 1

use

Connection conn = Db.withConnection(); //instead of DB.getConnection()

If that doesn't work than use the latest BoneCp version and add this in your SBT. (Apparently there has been issues with the way BoneCP handles Connection.)

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 += ...

Please refer the boneCP GitHub page that mentions this issue.

And please let me know if this helps you out.

Incpetor
  • 1,293
  • 6
  • 25
  • 46