diff --git a/src/brpc/policy/redis_protocol.cpp b/src/brpc/policy/redis_protocol.cpp index 67e5213307..94524e8b75 100644 --- a/src/brpc/policy/redis_protocol.cpp +++ b/src/brpc/policy/redis_protocol.cpp @@ -190,7 +190,9 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket, wopt.ignore_eovercrowded = true; LOG_IF(WARNING, socket->Write(&sendbuf, &wopt) != 0) << "Fail to send redis reply"; - ctx->arena.clear(); + if(ctx->parser.ParsedArgsSize() == 0) { + ctx->arena.clear(); + } return MakeParseError(err); } else { // NOTE(gejun): PopPipelinedInfo() is actually more contended than what diff --git a/src/brpc/redis_command.cpp b/src/brpc/redis_command.cpp index 2396e457df..13c93e417c 100644 --- a/src/brpc/redis_command.cpp +++ b/src/brpc/redis_command.cpp @@ -361,6 +361,10 @@ RedisCommandParser::RedisCommandParser() , _length(0) , _index(0) {} +int RedisCommandParser::ParsedArgsSize() { + return _args.size(); +} + ParseError RedisCommandParser::Consume(butil::IOBuf& buf, std::vector* args, butil::Arena* arena) { diff --git a/src/brpc/redis_command.h b/src/brpc/redis_command.h index fc88399570..48b3831040 100644 --- a/src/brpc/redis_command.h +++ b/src/brpc/redis_command.h @@ -53,6 +53,7 @@ class RedisCommandParser { // in `arena'. ParseError Consume(butil::IOBuf& buf, std::vector* args, butil::Arena* arena); + int ParsedArgsSize(); private: // Reset parser to the initial state.