jdbc4.CommunicationsException: Communications link failure
Did someone face such an error happening in case of some queries execution? (jdbc4.CommunicationsException: Communications link failure)
Generally, this exception means some problem of communication between application and mysql. And you can find a lot of suggestions posted regarding possib开发者_StackOverflowle reason.
Nothing helped in our case, and after several hours of investigation it turned out that the reason can be completely other.
Maybe the answer below will save someones time :)So, it turned out that the reason can be a corruption of mysql data file!! Actually, it can be corrupted the way that mysql is normally functioning for the most of queries.
If you find the query which executes application (when CommunicationsException is thrown) and execute it directly, e.g. in SQLyog, you will see:
Error Code : 2013
Lost connection to MySQL server during query
First of all, have a look on domain.err log file of mysql. If you have similar case, there should be lots of errors reported, including message like:
InnoDB: Database page corruption on disk or a failed
What we have done to solve the situation quickly - we set "innodb_force_recovery" to 1. This means directive to MySQL: Let the server run even if it detects a corrupt page.
CommunicationsException disappears after setting this, and what remains - "simply" DB data recovery ;-)
All the best,
Edgar
精彩评论