set maxIdleTime, maxIdleTimeExcessConnections of C3P0

Bug #602359 reported by Archer
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
play framework
New
Undecided
Unassigned

Bug Description

Because the default timeout of MySQL Connection is 8 hours, if a Play! application has been idle for over 8 hours, the instances of java.sql.Connection managed in C3P0 pool are out-of-date because they were closed by MySQL.

So we had better set the maxIdleTime and maxIdleExcessConnections of C3P0 in onApplicationStart method of class play.db.DBPlugin, such that maxIdelTime < 8 hours

Otherwise , we may need to restart the Play! application in a time.

Revision history for this message
Archer (ggd543) wrote :
Download full text (3.4 KiB)

Here is the error message :

play.exceptions.DatabaseException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:

** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
MESSAGE: The last packet successfully received from the server was 45,024,887 milliseconds ago. The last packet sent successfully to the server was 45,024,888 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

STACKTRACE:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 45,024,887 milliseconds ago. The last packet sent successfully to the server was 45,024,888 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
 at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
 at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
 at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3291)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1938)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2642)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2571)
 at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1451)
 at com.mchange.v2.c3p0.impl.NewProxyStatement.executeQuery(NewProxyStatement.java:35)
 at play.modules.elggdb.ElggDB$.executeQuery(ElggDB.scala:111)
 at play.modules.elggdb.ElggDB$.initELGG_META_ID(ElggDB.scala:43)
 at play.modules.elggdb.ElggDB$.initElggDB(ElggDB.scala:38)
 at play.modules.elggdb.ElggDBPlugin.onApplicationStart(ElggDBPlugin.scala:137)
 at play.Play.start(Play.java:386)
 at play.Play.detectChanges(Play.java:493)
 at play.Invoker$Invocation.init(Invoker.java:98)
 at Invocation.HTTP Request(Play!)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
 at java.net.SocketOutputStream.socketWrite0(Native Method)
 at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
 at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
 at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
 at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
 at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3272)
 ... 14 more

** END NESTED EXCEPTION **

 at play.modules.elggdb.ElggDB$.executeQuery(ElggDB.scala:114)
 at play.modules.elggdb.ElggDB$.initELGG_META_ID(ElggDB.scala:43)
 at play.modules.elggdb.ElggDB$.initElggDB(ElggDB.scala:38)
 at play.modules.elggdb.ElggDBPlugin.onApplicationStart(ElggDBPlugin.scala:137)
 at play.Play.start(Play.java:386)
 at play.Play.detectChanges(...

Read more...

Niko Schmuck (niko-nava)
tags: added: c3p0
tags: added: configuration database
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.