1 详细异常信息
ERROR yarn.ApplicationMaster: User class threw exception: java.sql.SQLException: Communications link failure The last packet successfully received from the server was 18,973 milliseconds ago. The last packet sent successfully to the server was 3 milliseconds ago. Query: select user_register_analyse_id as userRegisterAnalyseId,day_time as dayTime,city_code as cityCode,city,city_province as cityProvince,province,total_user_register_count as totalUserRegisterCount,day_user_register_count as dayUserRegisterCount,first_order_user_count as firstOrderUserCount,day_user_register_ordered_conversion_rate as dayUserRegisterOrderedConversionRate from t_user_register_analyse where day_time = ? and city_code = ? limit 1 Parameters: [2019-09-01 00:00:00, 130900] java.sql.SQLException: Communications link failure
2 检查一下自己的msyql连接是否关闭
解决方案:
第一步,先设置下mysql连接的过期时间,让mysql会自动释放连接
set global wait_timeout=30
set global interactive_timeout=30
或者 修改my.cnf 重启mysql
[mysqld]
wait_timeout=30
interactive_timeout=30
第二步,代码中手动关闭连接,根据自己用的代码api,自己检查下,是否把执行完sql后,关闭资源或者将连接还给线程池。