Statement cancelled due to timeout or client request

tomcat日志报错:

org.springframework.dao.QueryTimeoutException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request
### The error may exist in file [/var/lib/tomcat8/webapps/ROOT/WEB-INF/classes/mappers/DeviceMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters

原因是,MySQL优化器执行计划 使用了错误的索引,导致一条SQL查询语句超时,需要30多秒,所以报错。

解决方法是使用 force index 提示 mysql 选择正确的索引。搞定。