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后,關閉資源或者將連接還給線程池。