【例外的誕生】
周五下午接到反饋,說客戶向我們系統發起API簽約失敗,立即查優付trans-business日志,在對簽約log進行鏈路追蹤時,發現如下例外,在往檔案服務器保存用戶證照圖片時,fastdfs出現例外,
2021-02-08 16:05:24.483 [ERROR] [clientBusiness_common_do_16127804955370E234] [com.yft.util.FastDFSUtils:86] 讀取fdfs組態檔失敗! org.csource.common.MyException: item "tracker_server" in file:/www/epaysch/tomcat-trans-8280/webapps/pctrans-business/WEB-INF/lib/pctrans-core-0.0.1-SNAPSHOT.jar!/fdfs_client.conf not found at org.csource.fastdfs.ClientGlobal.init(ClientGlobal.java:102) at com.yft.util.FastDFSUtils.upload(FastDFSUtils.java:84) at com.cn.yft.pay.service.impl.SignContractServiceImpl.doBusiness(SignContractServiceImpl.java:163) at com.cn.yft.merchant.controller.ClientBusinessController.doBusiness(ClientBusinessController.java:227)
【快速回應:】
- 前一天的周四是例行上線日,由此可以確認這個問題是上線導致的,通過例外資訊: item "tracker_server" in file:/www/epaysch/tomcat-trans-8280/webapps/pctrans-business/WEB-INF/lib/pctrans-core-0.0.1-SNAPSHOT.jar!/fdfs_client.conf not found, 檔案不存在?在確認master分支代碼的組態檔正常后,趕緊找世偉確認pctrans-core這個jar里是不是缺少了這個檔案,經查,并未少,
- 初步分析是因為fdfs_client.conf不是properties檔案導致的,就像我們讀.cer證書一樣,從.jar里是讀不到的,就是說,這種檔案應該在/www/epaysch/tomcat-trans-8280/webapps/pctrans-business/WEB-INF/classes/下面,
- 不過,最重要的是先解決問題,經過與在洲、明輝初步溝通,可以對昨天夜間發版的trans進行回滾,于是,找世偉,先回滾代碼,保證系統可以正常使用,(2021年2月9日確認一共影響15筆帶照片的簽約)
【前一晚的發版內容】
我們的優付專案工程里有這么3個module,其中,trans-business和trans-provider是主應用,二者都依賴trans-core,因為要區分dev/test/prod環境,二者都包含了許多環境配置properties檔案,比如jdbc.properties、fastDFS.properties、fdfs_client.conf、redis.properties,還有其他的與系統相關的properties檔案,如bank_config.properties、levy.properties、business_config.properties等等,
由于涉及到配置改動時,可能要同時改兩個專案,而不知情的開發成員會出現漏改,所以這次需求迭代開發程序中,我們決定將共同的組態檔統一封裝到trans-core里,

這次發版比較順利,不過還是出現了這個敗筆,人有千慮,難免有一失呀!
【fastdfs出現例外的代碼】
如下 FastDFSUtils#upload,本案例外在加粗行拋出和捕獲,
/** * 上傳圖片回傳9 * * @param pic 圖片二進制 * @param name 名字 * @param size 大小 * @return 圖片的路徑(不包括ip和埠) * @throws Exception */ //上傳圖片 回傳圖片路徑 public static String upload(byte[] pic, String name, Long size) throws Exception { //全域設定IP 埠 引數 fdfs_client.conf ClassPathResource resource = new ClassPathResource("fdfs_client.conf"); //設定成功 try { ClientGlobal.init(resource.getClassLoader().getResource("fdfs_client.conf").getPath()); } catch (Exception e) { logger.error("讀取fdfs組態檔失敗!", e); } //ip 15683 TrackerClient trackerClient = new TrackerClient(); //創建連接 TrackerServer trackerServer = null; try { trackerServer = trackerClient.getConnection(); } catch (IOException e) { logger.error("創建tracker連接時失敗!", e); } ,,, }
【解決方案】
接下來是按初步思路來修改程式,在測驗環境測驗,證實原先的分析是ok的,解決方案就是把 fdfs_client.conf 原路移植回trans-business和trans-provider里,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/258609.html
標籤:其他
