最近發現數據服務日志大量報出thrift異常,拋出TTransportException,定位到thrift源代碼thrift/server/TThreadPoolServer.h中,發現代碼作者是這樣寫的。
if (!processor_->process(input_, output_, connectionContext) || !input_->getTransport()->peek()) { break; } } } catch (const TTransportException&) { // This is reasonably expected, client didn't send a full request so just // ignore him // string errStr = string("TThreadPoolServer client died: ") }
是因為client發出的請求不完全,thrift的框架會自動將thrift接口文件中的方法,例如test()接口,在它生成的service文件中是這樣子的:
void test() { send_test(); recv_test(); } void send_test(); void recv_test();
這三個接口client都可以使用,所以client可能調用了send_test()接口后,直接關閉了transport(反正沒有調用recv_test()),通過這樣的方式來實現異步。
就像作者代碼里面寫的一樣:just ignore him!