This is just an example from heroku log.
2011-12-02T01:01:14+00:00 app[web.1]: [error] c.j.b.ConnectionHandle -
Database access problem. Killing off all remaining connections in the
connection pool. SQL State = 08S01
2011-12-02T01:01:14+00:00 app[web.1]: [error] application -
2011-12-02T01:01:14+00:00 app[web.1]:
2011-12-02T01:01:14+00:00 app[web.1]: ! @68i0mf77p - Internal server
error, for request [GET /equipment] ->
2011-12-02T01:01:14+00:00 app[web.1]:
2011-12-02T01:01:14+00:00 app[web.1]: play.core.Invoker$$anonfun
$receive$1$$anon$1: Execution exception [[CommunicationsException:
Communications link failure
2011-12-02T01:01:14+00:00 app[web.1]:
2011-12-02T01:01:14+00:00 app[web.1]: The last packet successfully
received from the server was 3,154,918 milliseconds ago. The last
packet sent successfully to the server was 7 milliseconds ago.]]
2011-12-02T01:01:14+00:00 app[web.1]: at play.core.Invoker$$anonfun
$receive$1.apply(Invoker.scala:54) [play_2.9.1-2.0-beta.jar:2.0-beta]
2011-12-02T01:01:14+00:00 app[web.1]: at play.core.Invoker$$anonfun
$receive$1.apply(Invoker.scala:40) [play_2.9.1-2.0-beta.jar:2.0-beta]
2011-12-02T01:01:14+00:00 app[web.1]: at akka.actor.Actor
$class.apply(Actor.scala:545) [akka-actor-1.2.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
play.core.Invoker.apply(Invoker.scala:37) [play_2.9.1-2.0-beta.jar:2.0-
beta]
2011-12-02T01:01:14+00:00 app[web.1]: at
akka.actor.LocalActorRef.invoke(ActorRef.scala:905) [akka-
actor-1.2.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) [akka-
actor-1.2.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: Caused by:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
2011-12-02T01:01:14+00:00 app[web.1]:
2011-12-02T01:01:14+00:00 app[web.1]: The last packet successfully
received from the server was 3,154,918 milliseconds ago. The last
packet sent successfully to the server was 7 milliseconds ago.
2011-12-02T01:01:14+00:00 app[web.1]: at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
~[na:1.6.0_20]
2011-12-02T01:01:14+00:00 app[web.1]: at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
57) ~[na:1.6.0_20]
2011-12-02T01:01:14+00:00 app[web.1]: at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
45) ~[na:1.6.0_20]
2011-12-02T01:01:14+00:00 app[web.1]: at
java.lang.reflect.Constructor.newInstance(Constructor.java:532) ~[na:
1.6.0_20]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-
java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:
1116) ~[mysql-connector-java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: Caused by: java.io.EOFException:
Can not read response from server. Expected to read 4 bytes, read 0
bytes before connection was unexpectedly lost.
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2540) ~[mysql-connector-
java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2990) ~[mysql-
connector-java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2979) ~[mysql-
connector-java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3520) ~[mysql-
connector-java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990) ~[mysql-
connector-java-5.1.17.jar:na]
2011-12-02T01:01:14+00:00 app[web.1]: at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151) ~[mysql-
connector-java-5.1.17.jar:na]
If I refresh the page it works fine. It seems sporadic at this
point. I'm using Scala with Anorm. Thanks.
With Connection pools like DBCP, I typically suggest actively using
settings like testOnBorrow for applications that are idle for long
periods of time. I'm not sure what your app is using for it's
connection pooling, but some of the parameters found here may be worth
playing with if you are using Play's pools.
http://www.playframework.org/documentation/1.2.3/configuration#db.pool.maxIdleTimeExcessConnections
You can read more details about MySQL idle timeouts here [http://
wiki.cloudbees.com/bin/view/RUN/
DatabaseGuide#HAvoidingDatabaseIdleTimeouts]. The specific settings
in that article won't help for your app on Heroku, but the general
approach will work it you properly tune the connection pool you are
using.
c3p0.maxIdleTimeExcessConnections=1800
c3p0.maxIdleTime=3600
c3p0.maxConnectionAge=3600
This tells the pool how long to wait before dumping old and idle
connections.
thanks
Daryl.
if (DB.getConnection().isClosed())
{
((org.hibernate.ejb.EntityManagerImpl)
JPA.em()).getSession().reconnect(DB.getConnection());
}
If you know a worse case timeout, changing the Hibernate configuration
as suggested above is probably the best solution though.
http://jolbox.com/forum/viewtopic.php?f=3&t=235
In my environment I needed to make sure the timeout applied was based
on the INTERACTIVE_TIMEOUT, not on the WAIT_TIMEOUT.
-Blake
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
--
Blake Matheny
tumblr.mobocracy.net
maxConnectionAge
idleMaxAge
connectionTestStatement
--
Guillaume Bort
> If you leave page idle
For how long?
Now for me setting:
db.default.maxConnectionAge=10 seconds
Works perfectly. Connections are automatically closed after 10
seconds. Then they are opened again on demand. Settings this value to
something like 4 hours should be ok in your case.
You can configure it using:
db.default.idleConnectionTestPeriod=5 minutes
(note than using a configuration lower than 1 minute doesn't work and
it's not needed anyway)