I am using JForum 2.1.8 and am finding that I am getting the following error randomly but often:
I think the error generally appears after I leave the page alone for a time (an hour or more) and then come back and try to go to another page (or hit the back button). Although this error is random, I can also reproduce it by killing the connection in MySQL Administrator by doing the following:
Go to the home page and click on the 'Test Forum' link;
Open MySQL Administrator on the 'Server Connections' pane and kill the connections to JForum;
Refresh the page in JForum and the error will occur;
Refresh the page again and JForum gets a new connection and shows the page.
The last three items are repeatable. I am using the:
I got the above debug by changing the debugUnreturnedConnectionStackTraces to true.
I would guess that once a connection times out JForum does not immediatly get a new connection on the next request but waits until the request afterwards to do so.
Any ideas please? [originally posted on jforum.net by klogger]
It looks like the server is closing the TCP/IP DB connections before the C3P0 pooling agent does. So the pooling agent is supplying connections that have been closed.
A couple of quick thoughts on how to fix this are... MySQL's JDBC driver URL has an autoReconnect parameter. Check that the URL in your config file has autoReconnect=true on it (and check the docs that I remembered this right).
Another possibility is that you either need to lengthen the connection timeout on the MySQL server or shorten the C3p0 pooling time to be less than the MySQL server timeout.
Thanks for the suggestion, they have given me a place to start looking into this problem.
I am really not sure what I am doing when it comes to the details of MySQL Administration or C3P0.
I assume that if I kill the threads to JForum through MySQL Administrator, then refresh the JForum page, I should actually get the page as I expect rather than the error message? My Assumption would be that if the thread has died, then C3P0 should start a new thread for this connection as it is a fresh request.
As I cannot really re-produce this error without killing the thread in MySQL Administrator, I will just need to wait and see if the changes I made had any effect. The changes I have made are:
Setting maxIdleTime=120 on the c3p0.extra.params
Setting connect_timeout to 150 (I assume it is in seconds as the default is 5) through a MySQL console
Does they look like sensible things to try?
With the above setting, if I kill the thread in MySQL Administrator, I still get the error message.