SQLException: timeout for a free connection

I am creating an application in java with Play Framework 2.0.4 . The application is deployed to heroku with the cleardb database.

Users get this random error:

 PlayException: Execution exception [[PersistenceException: java.sql.SQLException: Timed out waiting for a free available connection.]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) at akka.actor.Actor$class.apply(Actor.scala:318) at play.core.ActionInvoker.apply(Invoker.scala:113) at akka.actor.ActorCell.invoke(ActorCell.scala:626) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) at akka.dispatch.Mailbox.run(Mailbox.scala:179) at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516) at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259) at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479) at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) 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:356) at com.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2021) at com.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:241) at com.avaje.ebeaninternal.server.core.DefaultServer.findId(DefaultServer.java:1212) at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.java:1118) at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.java:1105) at play.db.ebean.Model$Finder.byId(Model.java:237) 

Now things get worse, and sometimes all users get the same error every time until I restart the application in heroku.

Any help or advice on debugging it?

+6
source share
4 answers

I think the problem is the same as Heroku / Play / BoneCp problems

Heroku will close the connections after 30 seconds.

+5
source

After adding boneCp 0.8.0.rc1, to Build.scala and

 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 

but I still got a timeout error, especially when I left the page open and then clicked refresh.

+2
source

I ran into the same problem. This problem occurred when there is a huge reuqest stream on your Play application and the game will not be able to support the database pool. To make the game convenient for supporting the database pool, you need to add below three points to you aplliaction.conf files

  • db.default.maxConnectionsPerPartition = 100 // this says that the max connection of your Play Framework must be supported
  • db.default.minConnectionsPerPartition = 10 // During startup, at least a lot of DB connections must have
  • db.default.acquireIncrement = 10 // As soon as the Db connection exceeds maxConnectionsPerPartition, how much does it need to assign more to the pool
+2
source

Hi, this question is also, did you manage to solve it? I searched about this on the Internet. Everyone says that you are not closing your database connections. But I don’t open them at all, I mean that playing will do it for me. They also found that the code only works on scala ..

The last "solution" that I found, but it does not work 100%, is in the configuration file. http://www.playframework.com/documentation/2.0/SettingsJDBC

0
source

Source: https://habr.com/ru/post/943868/


All Articles