简体   繁体   中英

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 possible 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, eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM