Skip to content

Conversation

@LuGuangWang
Copy link

use the mysql offen occur this Error. Error querying database. Cause:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet
successfully received from the server was 19,800,056 milliseconds ago.
The last packet sent successfully to the server was 19,800,056
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.

Reason:
Use pooled datasource ,the idle connection could be invalid, when access
the msyql 'wait_timeout'. When call the close method to close this
connection, sometimes skip the 'pingConnection' method, so put a invalid
connection to idle Map.

my test:
2016-06-17 17:45:55,818 DEBUG [pool-1-thread-2] - Closing JDBC
Connection [com.mysql.jdbc.JDBC4Connection@7646d452] 1984353362
2016-06-17 17:45:55,818 DEBUG [pool-1-thread-2] -
============1984353362============= 0 0
(conn.getTimeElapsedSinceLastUse():0 poolPingConnectionsNotUsedFor:0)
2016-06-17 17:45:55,819 DEBUG [pool-1-thread-2] - Returned connection
1984353362 to pool.

solve this to ping connection before use.

wangluguang added 2 commits June 20, 2016 17:19
use the mysql offen occur this Error. Error querying database.  Cause:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet
successfully received from the server was 19,800,056 milliseconds ago.
The last packet sent successfully to the server was 19,800,056
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.

Reason:
Use pooled datasource ,the idle connection could be invalid, when access
the msyql 'wait_timeout'. When call the close method to close this
connection, sometimes skip the 'pingConnection' method, so put a invalid
connection to idle Map.

my test:
2016-06-17 17:45:55,818 DEBUG [pool-1-thread-2] - Closing JDBC
Connection [com.mysql.jdbc.JDBC4Connection@7646d452] 1984353362
2016-06-17 17:45:55,818 DEBUG [pool-1-thread-2] -
============1984353362============= 0 0
(conn.getTimeElapsedSinceLastUse():0 poolPingConnectionsNotUsedFor:0)
2016-06-17 17:45:55,819 DEBUG [pool-1-thread-2] - Returned connection
1984353362 to pool.


solve this to ping connection before use.
@harawata
Copy link
Member

The attached test case does not fail even without the proposed change.
Could you show me exactly how to reproduce the error?
Please see the similar report #748 as an example.
Thank you!

@LuGuangWang
Copy link
Author

Ok, may the same problem.
but,I Set PoolPingConnectionsNotUsedFor is 0 for using,now. thanks.

@harawata
Copy link
Member

OK. Thank you for your time!

@LuGuangWang LuGuangWang deleted the 3.3.x branch June 5, 2017 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants