W-Xu opened a new issue, #3207:
URL: https://github.com/apache/brpc/issues/3207
**Describe the bug**
在客户端的 proto 文件添加新字段之后,服务端未更新的情况下(proto文件见附录),高 qps 的情况下 ParsePbFromIOBuf
会稳定小概率反序列化解析失败。报错路径为:
http_rpc_protocol.cpp文件
if (content_type == HTTP_CONTENT_PROTO) {
if (!ParsePbFromIOBuf(req, req_body)) {
cntl->SetFailed(EREQUEST, "Fail to parse http body as
%s",
request_full_name.c_str());
return;
}
……
protocol.cpp文件
bool ParsePbFromIOBuf(google::protobuf::Message* msg, const butil::IOBuf&
buf) {
butil::IOBufAsZeroCopyInputStream stream(buf);
return ParsePbFromZeroCopyStreamInlined(msg, &stream);
}
如果把 [IOBufAsZeroCopyInputStream](butil::IOBufAsZeroCopyInputStream
stream(buf);) 修改为
std::string flat;
buf.copy_to(&flat);
// 用 ArrayInputStream代替
google::protobuf::io::ArrayInputStream ais(flat.data(), flat.size());
问题就会修复。
1、辛苦确认一下,这个地方是否有问题?或者有更好的使用建议吗?
2、如果有问题,这个地方用的 IOBufAsZeroCopyInputStream 看起来是问题所在,是否有更好修改建议?
附录:
proto文件
message BatchRequest {
string aaa = 1;
repeated int32 bbb = 2;
string ccc = 3;
repeated Request requests = 4;
int32 ddd = 5;
repeated uint64 eee = 6;
int32 fff = 7;
// Optional. name
// 客户端添加这个字段,服务端不添加这个字段有问题
string name = 8;
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]