Reputation: 1682
I have an app that uses MySql to save into a table (This table has 2 JSON fields and one of the can receive a large input). Every now and then in production I'm having the getting the following error:
SqlExceptionHelper - The last packet successfully received from the server was 71,290,382 milliseconds ago.
The last packet sent successfully to the server was 71,290,384 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.
I'm not understanding why this happens, since localy I never faced this issue. This is the configuration I currently have:
cfg.setProperty("hibernate.c3p0.min_size", "5")
.setProperty("hibernate.c3p0.max_size", "20")
.setProperty("hibernate.c3p0.timeout", "30000")
.setProperty("hibernate.c3p0.max_statements", "50")
.setProperty("hibernate.c3p0.idle_test_period", "3000")
.setProperty("hibernate.connection.autoReconnect", "true")
.setProperty("hibernate.connection.autoReconnectForPools", "true");
Am I missing something?.
Upvotes: 0
Views: 652
Reputation:
We had the same issue a while back. I was searching in the history and while you can keep the values that you have, you would need to add this one: <property name="connection.is-connection-validation-required">true</property>
. That did the trick for our artifact, but you would need to check in your case since you may have some other settings.
As a side note, I believe it should be:
.setProperty("connection.autoReconnect", "true")
.setProperty("connection.autoReconnectForPools", "true");
We also had a c3p0.properties
file:
c3p0.preferredTestQuery=select 1 from dual
c3p0.maxConnectionAge=3600
c3p0.testConnectionOnCheckin=false
c3p0.testConnectionOnCheckout=true
c3p0.acquireRetryDelay=1500
c3p0.acquireRetryAttempts=15
c3p0.breakAfterAcquireFailure=false
c3p0.idleConnectionTestPeriod=200
Pay attention to testConnectionOnCheckout in particular.
Upvotes: 1