[play-2.2] Database exceptions since upgrade

4,401 views
Skip to first unread message

Niklas Nylund

unread,
Nov 5, 2013, 3:13:15 AM11/5/13
to play-fr...@googlegroups.com

Since upgrading we have started to see some exceptions from time to time that didn't happen previously. We are using Play with Ebean and MySQL, has anyone seen similar behavior to this? The exceptions are thrown in controller actions not doing anything special (no async stuff, akka etc), it's just a web page and we have very light load. This is kind of odd since there hasn't been an update to Ebean in a year (i think). 


Caused by: javax.persistence.PersistenceException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
 at com
.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:339)
 at com
.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2018)
 at com
.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:178)
 at com
.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1459)
 at com
.avaje.ebeaninternal.server.core.DefaultBeanLoader.loadMany(DefaultBeanLoader.java:140)
 at com
.avaje.ebeaninternal.server.core.DefaultServer.loadMany(DefaultServer.java:499)
 at com
.avaje.ebeaninternal.server.loadcontext.DLoadManyContext.loadMany(DLoadManyContext.java:139)
 at com
.avaje.ebean.common.AbstractBeanCollection.lazyLoadCollection(AbstractBeanCollection.java:127)
 at com
.avaje.ebean.common.BeanSet.init(BeanSet.java:91)
 at com
.avaje.ebean.common.BeanSet.size(BeanSet.java:279)
......



Caused by: javax.persistence.PersistenceException: java.sql.SQLException: Timed out waiting for a free available connection.
       at com.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:339)

       at com.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2018)    
             
at com.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:178)

       at com.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1459)

       at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findList(DefaultOrmQuery.java:885)

      ... 48 more

Caused by: java.sql.SQLException: Timed out waiting for a free available connection.

       at com.jolbox.bonecp.DefaultConnectionStrategy.getConnectionInternal(DefaultConnectionStrategy.java:87)

       at com.jolbox.bonecp.AbstractConnectionStrategy.getConnection(AbstractConnectionStrategy.java:90)

       at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:540)

       at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:131)

       at play.db.ebean.EbeanPlugin$WrappingDatasource.getConnection(EbeanPlugin.java:147)

       at com.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:313)
.....



virtualeyes

unread,
Nov 5, 2013, 10:03:42 AM11/5/13
to play-fr...@googlegroups.com
What does
play> dependencies

show for boneCP version?

Niklas Nylund

unread,
Nov 5, 2013, 12:42:35 PM11/5/13
to play-fr...@googlegroups.com
Right, I found quite a few posts about problems with BoneCP while googling about this issue today.

dependencies says we are running with com.jolbox:bonecp:0.8.0-rc1. Should it be a newer one?


Niklas
> --
> You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/7PBnjiXkNuU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Niklas Nylund

unread,
Nov 6, 2013, 3:45:53 AM11/6/13
to play-fr...@googlegroups.com
There seems to be a slightly newer version, BoneCP 0.8.0 Release. I'll try that and see if it helps. 

We are now seeing a couple of these exceptions every night so it may be caused by the BoneCP bug that has been discussed earlier, we have close to no traffic during the night and maybe the GC isn't run then and connections aren't freed.



Niklas
> To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.

Niklas Nylund

unread,
Nov 6, 2013, 3:50:35 AM11/6/13
to play-fr...@googlegroups.com
Hmm, how do I get Play/SBT to pick up the new version? I added   "com.jolbox" % "bonecp" % "0.8.0-RELEASE"  to plugins.sbt but dependencies still show that I am using rc1.


Niklas

Emre Çelikten

unread,
Nov 6, 2013, 6:16:29 AM11/6/13
to play-fr...@googlegroups.com
> To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.

Niklas Nylund

unread,
Nov 6, 2013, 6:44:40 AM11/6/13
to play-fr...@googlegroups.com
Thanks for the link but unfortunately I am not able to get Play to pull in a new version of BoneCP.

I still get this when running dependencies,

| com.jolbox:bonecp:0.8.0-rc1                                       | com.typesafe.play:play-jdbc_2.10:2.2.0                 | As bonecp-0.8.0-rc1.jar                  |
|                                                                   | default:cmsapi_2.10:1.0-SNAPSHOT                       |                                          |
+-------------------------------------------------------------------+--------------------------------------------------------+------------------------------------------+

My build.sbt file looks like this,

name := "cmsapi"

version := "1.0-SNAPSHOT"

play.Project.playJavaSettings

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  "org.avaje.ebeanorm" % "avaje-ebeanorm-api" % "3.1.1",
  "mysql" % "mysql-connector-java" % "5.1.18",
  "com.typesafe" %% "play-plugins-mailer" % "2.1-RC2",
  "commons-collections" % "commons-collections" % "2.1.1",
  "org.jdom" % "jdom" % "2.0.2",
  "commons-io" % "commons-io" % "2.4",
  "commons-lang" % "commons-lang" % "2.6",
  "commons-codec" % "commons-codec" % "1.8",
  "com.typesafe.play" %% "play-jdbc" % "2.2.0" exclude("com.jolbox", "bonecp"),
  "com.jolbox" % "bonecp" % "0.8.0.RELEASE"
)   


Niklas

Emre Çelikten

unread,
Nov 6, 2013, 7:45:00 AM11/6/13
to play-fr...@googlegroups.com
Hello again,

Just asking to be sure: Have you tried reload and clean commands after changing your build.sbt?

Emre

virtualeyes

unread,
Nov 6, 2013, 11:06:32 AM11/6/13
to play-fr...@googlegroups.com
RC1 is asking for a hosing, everyone on 2.2 really needs 0.8 stable (likely one of the motivations for the quick 2.2.1 release).

Do something like this in your Build.scala:

object ApplicationBuild extends Build {
 
import Deps._

  val rootDeps
= bonecp ++ Seq(postgres, cache) ++ pdf
  lazy val root
= play.Project("flubagge", "0.1.0", rootDeps, ...)

 
object Deps {
   
...
    val bonecp
= Seq(

     
"com.typesafe.play" %% "play-jdbc" % "2.2.0" exclude("com.jolbox", "bonecp"),
     
"com.jolbox" % "bonecp" % "0.8.0.RELEASE"
   
)
 
}
}

Play 2.2's built-in "jdbc" dep pulls in the to-be-avoided 0.8 RC1, which takes precedence over whatever you specify as the bonecp dep, so we manually exclude the f-er, thereby experience stability ;-)

Once in a great while I get a transient connection exception, but that may be network related, or perhaps caused by Linux and its uber long default keepalive

Good luck...

Niklas Nylund

unread,
Nov 7, 2013, 3:42:39 AM11/7/13
to play-fr...@googlegroups.com
Thanks for the tip.

I somehow completely missed that 2.2.1 is out now and it should have a new bonecp. I'll try upgrading to that first.

Niklas

Niklas Nylund

unread,
Nov 8, 2013, 3:49:23 AM11/8/13
to play-fr...@googlegroups.com
FYI since upgrading one project to 2.2.1 we only saw one of these exceptions during last night instead of 5-10. While this is better it's still a bit worrying.

Niklas

Michael Seid

unread,
Nov 11, 2013, 1:15:23 PM11/11/13
to play-fr...@googlegroups.com
Let me know if there is any update on this. I am also experiencing this, and not sure how to fix it.

Thanks for reporting this and helping.  I look forward to any news.

Niklas Nylund

unread,
Nov 11, 2013, 1:49:11 PM11/11/13
to play-fr...@googlegroups.com
2.2.1 and the new version of BoneCP doesn't fix this. I haven't found any work around for this.


Niklas

Jxtps

unread,
Nov 11, 2013, 3:06:06 PM11/11/13
to play-fr...@googlegroups.com
We are also seeing this issue on 2.2.1.

Niklas Nylund

unread,
Nov 11, 2013, 3:52:43 PM11/11/13
to play-fr...@googlegroups.com
Has anyone successfully downgraded BoneCP to the older version that was used in 2.1.x?

Niklas

virtualeyes

unread,
Nov 11, 2013, 4:17:52 PM11/11/13
to play-fr...@googlegroups.com
Likewise, same here, still occurring.

Is BoneCP 0.8 stable or is this Play 2.2 specific?

virtualeyes

unread,
Nov 12, 2013, 2:22:20 AM11/12/13
to play-fr...@googlegroups.com
Trying to sort out where these errors are coming from; the variables at play that I can see are:

1) Underlying DB will have a default idle connection timeout (mine is 8H)
2) Play's default idleConnectionMaxAge for BoneCP is 1H.
3) OS has its own default KeepAlive (2H on RedHat based distros).

In this scenario the OS never keeps the inactive connection alive since 2H > 1H, the BoneCP idle timeout. It is unlikely that the DB is closing connections given the 8H timeout (no DB log entries to that effect in my case), so it would appear that BoneCP is for some reason not properly closing idle connections, or is attempting to recycle already closed connections rather than drawing an active connection from the pool.

Side note: while benchmarking my application I increased the number of available threads (i.e. overriding Play default akka config) well beyond actual day-to-day server load. I left the benchmark config in place and have seen a 10X increase in jdbc.SQLError.createSQLException errors.

Probably best to tune the akka thread pool as close as possible to real life load in order to minimize the damage of whatever is happening with BoneCP and idle connections.

Niklas Nylund

unread,
Nov 12, 2013, 8:25:26 AM11/12/13
to play-fr...@googlegroups.com
I haven't had time to debug this now but in our case it happens mostly with a database that has light load and most likely is idle for long stretches. Most exceptions seems to be thrown when googlebot finds the pages in the middle of the night and causes a lot of requests. This is all circumstantial but it points towards the same things you mention about idle connections.

Niklas

virtualeyes

unread,
Nov 12, 2013, 4:39:16 PM11/12/13
to play-fr...@googlegroups.com
After trimming down pool size appropriate to actual server load, now I see the pattern:

At least 1 hour between errors, which is default max idle in play config I believe.

This can occur at anytime of day, so the oh-it's-just-a-bot notion doesn't apply.

Solution must be to just hammer one's site with traffic 24/7, if one could be so lucky ;-)

Niklas Nylund

unread,
Nov 19, 2013, 9:57:33 AM11/19/13
to play-fr...@googlegroups.com
Can someone from the core team comment on this? Do you have anything in production with the default Java stack and also getting these errors?

How do I go about downgrading BoneCP?


Niklas

Volker Hatz

unread,
Nov 19, 2013, 2:11:01 PM11/19/13
to play-fr...@googlegroups.com
I am also surprised that this is not treated more offensively. This is a pretty annoying bug and its hard to recommend to go productive with that error.

I have combined both proposed configuration changes and this seems to work. But time will tell.

application.conf: added db.default.connectionTestStatement="SELECT 1"
ApplciationBuild: remove "jdbc" and add:
    "com.typesafe.play" %% "play-jdbc" % "2.2.0" exclude("com.jolbox", "bonecp"),
    "com.jolbox" % "bonecp" % "0.8.0.RELEASE" 

Anyhow this cannot be a final solution.

Niklas Nylund

unread,
Nov 21, 2013, 5:55:30 AM11/21/13
to play-fr...@googlegroups.com
On Tuesday, November 19, 2013 9:11:01 PM UTC+2, Volker Hatz wrote:
I am also surprised that this is not treated more offensively. This is a pretty annoying bug and its hard to recommend to go productive with that error.

I have combined both proposed configuration changes and this seems to work. But time will tell.

application.conf: added db.default.connectionTestStatement="SELECT 1"

This seems to help somewhat but it doesn't fix the problem completely for us. The amount of errors in our logs have dropped over the last 2 days with roughly 75% after I added this.


Niklas

virtualeyes

unread,
Nov 22, 2013, 4:34:13 AM11/22/13
to play-fr...@googlegroups.com
Interesting, I thought that "Select 1" was the BoneCP default, which would mean this really has no affect:
db.default.connectionTestStatement="SELECT 1"

As setting it or not will result in the same thing.

What stopped the problem entirely was setting:
maxConnectionAge=0

Not a single connection error in 72 hours, vs. several per day.

Note: am also on 0.8.1-snapshot (to get fix for prepared statement cache bug found in 0.8-release), so not sure if that has also improved stability.

Volker Hatz

unread,
Nov 22, 2013, 5:06:15 AM11/22/13
to play-fr...@googlegroups.com
When I added the "Select 1" I got rid of the issues. Also I have the logging of database statements "on". It only shows the "Select 1" when you add it as a db.default.connectionTestStatement property.

virtualeyes

unread,
Nov 22, 2013, 5:11:14 AM11/22/13
to play-fr...@googlegroups.com
Thanks, you're right, I just checked BoneCP default config, they fallback to a slower db agnostic metadata test statement if not set.

Will add that in now ;-)

Michael Seid

unread,
Nov 24, 2013, 6:53:51 PM11/24/13
to play-fr...@googlegroups.com
Do you mind sharing some Build.scala and your application.conf snippets? I still am running into these errors.  All of these configs have helped, but it still comes up about 3 to 4 times a day.  

Thanks for your help.

virtualeyes

unread,
Nov 25, 2013, 4:57:08 AM11/25/13
to play-fr...@googlegroups.com
Are you on Play 2.2.1 or manually pulling in BoneCP 0.8.0 via an earlier version of Play?

I ask because it sounds like some users have found stability with 0.8.0 and there may be no need for 0.8.1-snapshot to address this particular issue. Play 2.2.1 comes with 0.8.0 out of the box so nothing to do short of setting:
maxConnectionAge=0

and perhaps setting connectionTestStatement specific to your DBMS (for MySQL, "SELECT 1").

Michael Seid

unread,
Nov 25, 2013, 11:53:26 AM11/25/13
to play-fr...@googlegroups.com
Thanks for the help! I am using 2.2.1 standard. But it still seems be borked for me. Also, I am connecting to a MySQL instance on Amazon RDS. Do you think there is any configuration I need to do their? Nothing changed over there, but I'm not sure if I should update any connection settings.

Here is my configuration. Any ideas?
db.default.partitionCount=2
db.default.maxConnectionsPerPartition=10
db.default.minConnectionsPerPartition=10
db.default.connectionTimeout=10 seconds
db.default.idleConnectionTestPeriod=1 minute
db.default.idleMaxAge=10 minutes
db.default.maxConnectionAge=0
db.default.initSQL="SELECT 1"
db.default.connectionTestStatement="SELECT 1"

Thanks for the help. This problem has really been a tough one to figure out.

virtualeyes

unread,
Nov 25, 2013, 4:07:36 PM11/25/13
to play-fr...@googlegroups.com
BoneCP author said partitionCount should = number of cpu core(s), so set accordingly for your ADS instance.

Unless your application is getting hammered, you may not need 20 connections in the pool created on startup, maybe try with a lower minConnections.

Check out Play's BoneCP defaults as well for reference.

Niklas Nylund

unread,
Nov 26, 2013, 7:30:23 AM11/26/13
to play-fr...@googlegroups.com
Adding,

db.default.maxConnectionAge=0
db.default.connectionTestStatement="SELECT 1"

with MySQL and 2.2.1 seems to do the trick, we haven't gotten any errors now for 48 hours.


Niklas

Bruno Leite

unread,
Nov 26, 2013, 9:06:29 AM11/26/13
to play-fr...@googlegroups.com
Not sure if this is going to help anyone but I had this "java.sql.SQLException: Timed out waiting for a free available connection." before, when I forgot to close a QueryIterator. 
The correct usage should be (for example) something like this:

QueryIterator<Some> iterator = Ebean.find(Some.class).findIterate();
try {     
     Ebean.delete(iterator);  
} finally {
     iterator.close();
}

If the iterator.close()is not invoked after using the QueryIterator, the DB connection will be kept open, meaning that after some time all DB connections are consumed but not released.

Michael Seid

unread,
Nov 26, 2013, 8:36:14 PM11/26/13
to play-fr...@googlegroups.com
Thanks for all the help guys. This seems to be working for me too. So far, so good. Haven't had any errors yet today.  Makes me feel much better.

ronik

unread,
Dec 1, 2013, 2:41:35 AM12/1/13
to play-fr...@googlegroups.com
I just hit the same problem and am hoping that the following lines will fix this problem:

db.default.maxConnectionAge=0
db.default.connectionTestStatement="SELECT 1"

Thinking of going into production with play soon so such bugs are always scary but the community-effect helps a bit. Play seems to have the potential but a large community will make it better.

Joe Zulli

unread,
Dec 9, 2013, 8:59:03 PM12/9/13
to play-fr...@googlegroups.com
Hi everyone,

I am getting the same error (No operations allowed after connection closed). I was getting it about 50 times a day. I then added the following lines mentioned above:

db.default.maxConnectionAge=0
db.default.connectionTestStatement="SELECT 1"

...and now I only get about 10 errors a day. Well, that's progress, but I'd love to get zero and stop getting paged. Has anyone had the above setting work for them, and are now getting zero errors? If so, would you mind sharing ALL of your db.default.* settings? Perhaps, there is something else I am doing in a different setting that is tripping it up.

Thanks in advance!
Joe

Jxtps

unread,
Dec 9, 2013, 9:03:10 PM12/9/13
to play-fr...@googlegroups.com
This seems to work for me:

db.default.connectionTimeout=10000
db
.default.maxConnectionAge=0
db
.default.connectionTestStatement="SELECT 1"
db
.default.driver=com.mysql.jdbc.Driver
# db.default.logStatements=true


Joe Zulli

unread,
Dec 10, 2013, 5:16:45 PM12/10/13
to play-fr...@googlegroups.com
Thanks Jxtps! It's been about 24 hours and I haven't gotten a single error. Interestingly, my settings were already very close to yours, but I also changed a couple of other defaults. Possibly, most importantly, I changes the app to have two partitions of 15 connections each, instead of the default of 1 partition of 30 connections. For those who are interested, here are the properties that I commented out to get it to work.

# db.default.partitionCount=2
# db.default.maxConnectionsPerPartition=15
# db.default.acquireRetryDelay=5 seconds

Hope that helps,
Joe

virtualeyes

unread,
Dec 11, 2013, 2:54:46 AM12/11/13
to play-fr...@googlegroups.com
That doesn't make any sense, the default partition count is 1, so when you comment out:
# db.default.partitionCount=2

You have 1 partition ;-)

The solution is:
db.default.maxConnectionAge=0

BoneCP author has stated that this setting forces a hard timeout on all connections, regardless of whether or not the connection is active.

Not sure why Play sets the default maxConnectionAge to 1 hour or whatever it is, but it does wreak havoc, AFAICT

Joe Zulli

unread,
Dec 11, 2013, 7:29:52 PM12/11/13
to play-fr...@googlegroups.com
Yeah, I don't get it either. I'd love to get to the bottom of this, but this is just.... weird.

Virtualeyes, you mentioned a few messages above that the BoneCP author recommends having exactly on partition per core. I was originally using 2 partitions, even though I'm on EC2 m1.medium instances, which I'm pretty sure are single core machines. I don't know why having more partitions than cores would hurt anything but do you think it could be related?

Joe

thoefer

unread,
Dec 12, 2013, 4:25:10 AM12/12/13
to play-fr...@googlegroups.com
How about setting "default.maxConnectionAge=0" in your application.conf?

Until now we've not experienced any issue of this sort. Using Play 2.2.1 with Scala and bonecp:0.8.0.RELEASE







Am Dienstag, 5. November 2013 09:13:15 UTC+1 schrieb Niklas Nylund:

Since upgrading we have started to see some exceptions from time to time that didn't happen previously. We are using Play with Ebean and MySQL, has anyone seen similar behavior to this? The exceptions are thrown in controller actions not doing anything special (no async stuff, akka etc), it's just a web page and we have very light load. This is kind of odd since there hasn't been an update to Ebean in a year (i think). 


Caused by: javax.persistence.PersistenceException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
 at com
.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:339)
 at com
.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2018)
 at com
.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:178)
 at com
.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1459)
 at com
.avaje.ebeaninternal.server.core.DefaultBeanLoader.loadMany(DefaultBeanLoader.java:140)
 at com
.avaje.ebeaninternal.server.core.DefaultServer.loadMany(DefaultServer.java:499)
 at com
.avaje.ebeaninternal.server.loadcontext.DLoadManyContext.loadMany(DLoadManyContext.java:139)
 at com
.avaje.ebean.common.AbstractBeanCollection.lazyLoadCollection(AbstractBeanCollection.java:127)
 at com
.avaje.ebean.common.BeanSet.init(BeanSet.java:91)
 at com
.avaje.ebean.common.BeanSet.size(BeanSet.java:279)
......



Caused by: javax.persistence.PersistenceException: java.sql.SQLException: Timed out waiting for a free available connection.
       at com.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:339)

       at com.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2018)    
             
at com.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:178)

       at com.avaje.ebeaninternal.server.core.DefaultServer.findList(DefaultServer.java:1459)

       at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findList(DefaultOrmQuery.java:885)

      ... 48 more

Caused by: java.sql.SQLException: Timed out waiting for a free available connection.

thoefer

unread,
Dec 12, 2013, 4:28:17 AM12/12/13
to play-fr...@googlegroups.com
ok, virtualeyes already suggested this setting... I can confirm that is works for us!

Niklas Nylund

unread,
Dec 16, 2013, 6:58:29 AM12/16/13
to play-fr...@googlegroups.com
Argh, we started getting these errors again a lot when we changed some of our analytics code. Basically we tried to optimize one action by moving some analytics database updates out of the request action. It's ok to update it later asynchronously after the request has been handled and a reply sent to the client.

I still haven't had time to try to make an isolated test case for this but it seems fairly reproducible and happens in production on a continuous basis. All we need to do is move a single database update into an Akka job and then we run into this:

Akka.system().scheduler().scheduleOnce(delay, runnableInstanceWithDbUpdates, Akka.system().dispatcher());

javax.persistence.PersistenceException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

at com.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:339)

at com.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2018)

at com.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:178)

at com.avaje.ebeaninternal.server.core.DefaultServer.findId(DefaultServer.java:1191)

at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.java:1046)

at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.java:1033)

at play.db.ebean.Model$Finder.byId(Model.java:261)

at models.analytics.TrackViewJob.runJob(TrackViewJob.java:34)

at controllers.helpers.Job$1.run(Job.java:30)

at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:42)

at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)

at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)

at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)

at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)

at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:534)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.Util.getInstance(Util.java:386)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)

at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1205)

at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1197)

at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4954)

at com.jolbox.bonecp.ConnectionHandle.setAutoCommit(ConnectionHandle.java:1292)

at play.api.db.BoneCPApi$$anon$1.onCheckOut(DB.scala:329)

at com.jolbox.bonecp.AbstractConnectionStrategy.postConnection(AbstractConnectionStrategy.java:75)

at com.jolbox.bonecp.AbstractConnectionStrategy.getConnection(AbstractConnectionStrategy.java:92)

at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:553)

at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:131)

at play.db.ebean.EbeanPlugin$WrappingDatasource.getConnection(EbeanPlugin.java:147)

at com.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:313)



How is Play handling this? Is the Akka job trying to use the same DB connection as the controller/request handler code, which in these cases is probably finished already and have given up its handle?

Niklas

Christopher Hunt

unread,
Jan 17, 2014, 1:07:58 AM1/17/14
to play-fr...@googlegroups.com

There may be a problem with Bonecp 0.8.0 regarding connection management. My fix for it is here:

https://github.com/playframework/playframework/pull/2009

Looks as though this didn’t make it into the 2.2.x branch though, which means that it didn’t make 2.2.2-RC1. I have now included it for 2.2.2-RC2:

https://github.com/playframework/playframework/pull/2009#issuecomment-32581152

We’ll shortly make a 2.2.2-RC2 followed by a 2.2.2 release soon thereafter.

Niklas Nylund

unread,
Jan 18, 2014, 11:13:22 AM1/18/14
to play-fr...@googlegroups.com
This looks interesting, thanks for the heads up.

I'll be sure to test this out, it's a bit tricky since we only see the errors in production under real load and I won't upgrade our stuff to 2.2.2 at release day right away but I will let you know if this fixes things.

Niklas

Christopher Hunt

unread,
Jan 18, 2014, 11:20:29 AM1/18/14
to play-fr...@googlegroups.com
Great, FYI - 2.2.2-RC2 is now available.

On 18/01/2014, at 5:13 PM, Niklas Nylund <nyl...@gmail.com> wrote:

This looks interesting, thanks for the heads up.

I'll be sure to test this out, it's a bit tricky since we only see the errors in production under real load and I won't upgrade our stuff to 2.2.2 at release day right away but I will let you know if this fixes things.

-- 
Christopher Hunt
Senior Engineer
Typesafe – Build Reactive Apps on the JVM!

Twitter: @huntchr

Thijs

unread,
Jan 31, 2014, 7:15:53 AM1/31/14
to play-fr...@googlegroups.com
I also have these problems, I'm running a Play 2.2.1 application in a production env and these random connection problems don't feel right. Seeing all these issues BoneCP doesn't seem so stable.

It would be great if I could easily choose a different, more proven, connection pool like c3p0. Is this possible?

virtualeyes

unread,
Jan 31, 2014, 4:23:10 PM1/31/14
to play-fr...@googlegroups.com
BoneCP author himself mentioned this seemingly too-good-to-be-true alternative:
https://github.com/brettwooldridge/HikariCP

Performance is through the roof compared to BCP and c3p0, no idea about stability...

Michael Slinn

unread,
Feb 1, 2014, 1:13:06 PM2/1/14
to play-fr...@googlegroups.com
Wow, those graphs are impressive. I wonder if a different connection pool for Play could be plugged in without adverse affect?

Niklas Nylund

unread,
Mar 13, 2014, 2:47:28 PM3/13/14
to play-fr...@googlegroups.com
2.2.2 seems to fix these issues for us, no errors yet and we have been in production for 48 hours+.

Niklas

Sebas

unread,
Mar 18, 2014, 2:00:07 PM3/18/14
to play-fr...@googlegroups.com
I have just encountered this problem with play 2.2.2.

Runtime was about a week in production.

Seems 2.2.2 has not yet fixed this issue.

virtualeyes

unread,
Mar 18, 2014, 5:09:17 PM3/18/14
to play-fr...@googlegroups.com
One time in a week, or are you getting several per day?

Also, is your database getting hammered 24/7? I've noticed the issue comes up pre 2.2.2 when the database is relatively idle.

Thinking about switching to HikaraiCP if Play supports alternative CPs.

Sebas

unread,
Mar 19, 2014, 4:37:38 AM3/19/14
to play-fr...@googlegroups.com
The database is relatively idle at the moment, it is far from being hammered 24/7. 
When the application will be used more this of course will change, and by searching google a bit I have found that the problem will probably occur a lot more often (unless it's fixed of course).

Annoying part of the problem is that you have to restart play to resolve it, so scheduling a daily restart by cron seems a workable, but really temporary solution.

Christopher Hunt

unread,
Mar 19, 2014, 8:30:34 AM3/19/14
to play-fr...@googlegroups.com
Can you please confirm that you're actually using 2.2.2 by checking the play plugin version. Thanks

Sebas

unread,
Mar 20, 2014, 4:43:45 AM3/20/14
to play-fr...@googlegroups.com
com.typesafe.play.play_2.10-2.2.2.jar

package created with dist command

sachin walia

unread,
Mar 20, 2014, 8:42:07 PM3/20/14
to play-fr...@googlegroups.com
I have developed my own Database Plugin using HirakiCP. There were multiple reasons for building my own plugin:
- I was getting too frequent "no available connection" error with Bonecp and postgres (almost everyday on play 2.2.2). With HirakiCP I havent seen this error for some time.
- I had a requirement to encrypt complete DB details in application.conf. This was not possible with current play DB plugin.
- Once the new Postgres driver is stable (https://github.com/impossibl/pgjdbc-ng) then I have a plan to switch to this. As of now I am getting some exception using it. However Database Plugin implementation is flexible and all it needs is setting a flag as true to switch to this new driver. This driver requires Netty 4.0 though and play I think still uses 3.x. I havent seen any compatibility issue in my application though.

So far I am very content with the overall results.

thanks,

Sachin Walia

Marcos Pereira

unread,
Mar 21, 2014, 8:34:11 PM3/21/14
to play-framework
Hi, Sachin, 

Do you have any plans to open source your plugin?

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sachin walia

unread,
Mar 21, 2014, 8:44:41 PM3/21/14
to play-fr...@googlegroups.com
Sure. I'll open source the plugin. I will just remove/alter my project specific code and make it open source. I'll try to complete it by this weekend.

Also, please note in order to use this plugin you'll have to remove the native DB plugin from play. I made this design choice to keep the development as simple as possible. However if there is lot of interest then people can enhance it as per their need.

thanks,

Sachin Walia

Oleg Smirnov

unread,
Mar 25, 2014, 11:20:29 AM3/25/14
to play-fr...@googlegroups.com
Hi,

See: https://bugs.launchpad.net/bonecp/+bug/1243551

I tried to roll back to the previous library BoneCP version 0.7.1.RELEASE, which had no problems.

val appDependencies = Seq(
   
//jdbc,
   anorm
,
   
"mysql" % "mysql-connector-java" % "5.1.26",
   
...
   
"com.typesafe.play" %% "play-jdbc" % "2.2.1" exclude("com.jolbox", "bonecp"),
   
"com.jolbox" % "bonecp" % "0.7.1.RELEASE"
 
)

Yann Simon

unread,
Apr 22, 2014, 12:04:53 AM4/22/14
to play-fr...@googlegroups.com
What is the current state of this problem?
Do you still experience problem with play 2.2 out of the box.
Does rollbacking the BoneCP version to 0.7.1.RELEASE fix this issue?

Alan Lavintman

unread,
Apr 22, 2014, 4:38:11 AM4/22/14
to play-fr...@googlegroups.com
Guys, We fall into this as well, any updates? We are currently upgrading to 2.2.2, any idea if the issue will continue to happen?

Bests, 
Alan.

Yann Simon

unread,
Apr 22, 2014, 4:49:28 AM4/22/14
to play-fr...@googlegroups.com
It would maybe help if somebody concerned by this problem opens an
issue on github.

Niklas Nylund

unread,
Apr 22, 2014, 1:44:12 PM4/22/14
to play-fr...@googlegroups.com
Since upgrading to 2.2.2 we haven't seen any of these errors, we used to get them multiple times a day previously.

Niklas 

You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/7PBnjiXkNuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.

Yann Simon

unread,
Apr 23, 2014, 4:26:23 PM4/23/14
to play-fr...@googlegroups.com


On Apr 22, 2014 7:44 PM, "Niklas Nylund" <nyl...@gmail.com> wrote:
>
> Since upgrading to 2.2.2 we haven't seen any of these errors, we used to get them multiple times a day previously.
>
> Niklas 

Thanks for the feedback!
Any other return of experience?

Niklas Nylund

unread,
Apr 24, 2014, 1:03:37 PM4/24/14
to play-fr...@googlegroups.com


On 23 apr 2014, at 23:26, Yann Simon <yann.s...@gmail.com> wrote:


On Apr 22, 2014 7:44 PM, "Niklas Nylund" <nyl...@gmail.com> wrote:
>
> Since upgrading to 2.2.2 we haven't seen any of these errors, we used to get them multiple times a day previously.
>
> Niklas 

Thanks for the feedback!
Any other return of experience?


No, not really. Everything is working as expected. The compilation speed up is also nice but I can't remember if that was in 2.2.2 or earlier.

Niklas

Fransiskus Xaverius

unread,
Jun 5, 2014, 1:05:56 PM6/5/14
to play-fr...@googlegroups.com
I am using Play 2.2.2 and still experiencing this problem. Any thoughts guys? I tried various solutions that I got online, but none of theme works.

-Frans

Rich Dougherty

unread,
Jun 5, 2014, 5:42:17 PM6/5/14
to play-framework
On Fri, Jun 6, 2014 at 5:05 AM, Fransiskus Xaverius <frans...@gmail.com> wrote:
I am using Play 2.2.2 and still experiencing this problem. Any thoughts guys? I tried various solutions that I got online, but none of theme works.

I'm sorry I don't have anything to suggest, except to say that issues relating to closed connections and connection pools can be very tricky to debug. E.g. the last Play connection pool issue I debugged was caused by a memory leak elsewhere in the app. As the GC load got higher, database connections started failing.

To debug you either need to develop a reproducible test case or you need to have excellent production monitoring or logging so you can correlate events while you're searching for a diagnosis.

Cheers
Rich

Nicolas Rémond

unread,
Oct 21, 2014, 4:08:40 PM10/21/14
to play-fr...@googlegroups.com
Suffered from the same kind of issues.
Ditched BoneCP for HikariCP - things are much more stable now.

Rupanjan Baidya

unread,
Oct 30, 2014, 12:48:31 PM10/30/14
to play-fr...@googlegroups.com, zetazonein
I am using Play 2.2.3! .. getting the same problem, here is the stack-trace,


! @6k3clo9h0 - Internal server error, for (POST) [/items/add/2] ->

play.api.Application$anon$1: Execution exception[[PersistenceException: java.sql.SQLException: Connection is closed!]]
at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10-2.2.3.jar:2.2.3]
at play.api.DefaultApplication.handleError(Application.scala:399) [play_2.10-2.2.3.jar:2.2.3]
at play.core.server.netty.PlayDefaultUpstreamHandler$anonfun$3$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:264) [play_2.10-2.2.3.jar:2.2.3]
at play.core.server.netty.PlayDefaultUpstreamHandler$anonfun$3$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:264) [play_2.10-2.2.3.jar:2.2.3]
at scala.Option.map(Option.scala:145) [scala-library.jar:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:264) [play_2.10-2.2.3.jar:2.2.3]

Caused by: javax.persistence.PersistenceException: java.sql.SQLException: Connection is closed!
at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:641) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:622) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.core.BeanRequest.rollbackTransIfRequired(BeanRequest.java:87) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:284) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.persist.DefaultPersister.save(DefaultPersister.java:248) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1568) ~[avaje-ebeanorm.jar:na]

Caused by: java.sql.SQLException: Connection is closed!
at com.jolbox.bonecp.ConnectionHandle.checkClosed(ConnectionHandle.java:459) ~[bonecp.jar:na]
at com.jolbox.bonecp.ConnectionHandle.rollback(ConnectionHandle.java:1270) ~[bonecp.jar:na]
at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:634) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:622) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.core.BeanRequest.rollbackTransIfRequired(BeanRequest.java:87) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:284) ~[avaje-ebeanorm.jar:na]


Nicolas,

Could you please share your build.sbt for HikariCP plugin?

Thanks in advance.

-RB

Laurent Fleuriot

unread,
Feb 4, 2015, 4:53:28 PM2/4/15
to play-fr...@googlegroups.com, zetaz...@gmail.com
Hello,

I have the same error. Have you find the issue?

Thanks in advance.
Laurent
Reply all
Reply to author
Forward
0 new messages