[fix](move-memtable) free resources when fail to open stream (#31762)

This commit is contained in:
Kaijie Chen
2024-03-05 19:06:00 +08:00
committed by yiguolei
parent 1434d3983b
commit c43bc8349f

View File

@ -164,7 +164,8 @@ Status LoadStreamStub::open(std::shared_ptr<LoadStreamStub> self,
opt.messages_in_batch = config::load_stream_messages_in_batch;
opt.handler = new LoadStreamReplyHandler(_load_id, _dst_id, self);
brpc::Controller cntl;
if (int ret = StreamCreate(&_stream_id, cntl, &opt)) {
if (int ret = brpc::StreamCreate(&_stream_id, cntl, &opt)) {
delete opt.handler;
return Status::Error<true>(ret, "Failed to create stream");
}
cntl.set_timeout_ms(config::open_load_stream_timeout_ms);
@ -192,6 +193,7 @@ Status LoadStreamStub::open(std::shared_ptr<LoadStreamStub> self,
resp.enable_unique_key_merge_on_write());
}
if (cntl.Failed()) {
brpc::StreamClose(_stream_id);
return Status::InternalError("Failed to connect to backend {}: {}", _dst_id,
cntl.ErrorText());
}