Coverage Report

Created: 2026-03-12 17:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/brpc_closure.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <google/protobuf/stubs/common.h>
21
22
#include <atomic>
23
#include <utility>
24
25
#include "runtime/query_context.h"
26
#include "runtime/thread_context.h"
27
#include "service/brpc.h"
28
29
namespace doris {
30
31
template <typename Response>
32
class DummyBrpcCallback {
33
    ENABLE_FACTORY_CREATOR(DummyBrpcCallback);
34
35
public:
36
    using ResponseType = Response;
37
4.78M
    DummyBrpcCallback() {
38
4.78M
        cntl_ = std::make_shared<brpc::Controller>();
39
4.78M
        call_id_ = cntl_->call_id();
40
4.78M
        response_ = std::make_shared<Response>();
41
4.78M
    }
_ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEC2Ev
Line
Count
Source
37
45
    DummyBrpcCallback() {
38
45
        cntl_ = std::make_shared<brpc::Controller>();
39
45
        call_id_ = cntl_->call_id();
40
45
        response_ = std::make_shared<Response>();
41
45
    }
_ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEEC2Ev
Line
Count
Source
37
1.66k
    DummyBrpcCallback() {
38
1.66k
        cntl_ = std::make_shared<brpc::Controller>();
39
1.66k
        call_id_ = cntl_->call_id();
40
1.66k
        response_ = std::make_shared<Response>();
41
1.66k
    }
_ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEC2Ev
Line
Count
Source
37
45
    DummyBrpcCallback() {
38
45
        cntl_ = std::make_shared<brpc::Controller>();
39
45
        call_id_ = cntl_->call_id();
40
45
        response_ = std::make_shared<Response>();
41
45
    }
_ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEEC2Ev
Line
Count
Source
37
2.48k
    DummyBrpcCallback() {
38
2.48k
        cntl_ = std::make_shared<brpc::Controller>();
39
2.48k
        call_id_ = cntl_->call_id();
40
2.48k
        response_ = std::make_shared<Response>();
41
2.48k
    }
_ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEEC2Ev
Line
Count
Source
37
66.4k
    DummyBrpcCallback() {
38
66.4k
        cntl_ = std::make_shared<brpc::Controller>();
39
66.4k
        call_id_ = cntl_->call_id();
40
66.4k
        response_ = std::make_shared<Response>();
41
66.4k
    }
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEC2Ev
Line
Count
Source
37
66.4k
    DummyBrpcCallback() {
38
66.4k
        cntl_ = std::make_shared<brpc::Controller>();
39
66.4k
        call_id_ = cntl_->call_id();
40
66.4k
        response_ = std::make_shared<Response>();
41
66.4k
    }
_ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEC2Ev
Line
Count
Source
37
121
    DummyBrpcCallback() {
38
121
        cntl_ = std::make_shared<brpc::Controller>();
39
121
        call_id_ = cntl_->call_id();
40
121
        response_ = std::make_shared<Response>();
41
121
    }
_ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEEC2Ev
Line
Count
Source
37
4.64M
    DummyBrpcCallback() {
38
4.64M
        cntl_ = std::make_shared<brpc::Controller>();
39
4.64M
        call_id_ = cntl_->call_id();
40
4.64M
        response_ = std::make_shared<Response>();
41
4.64M
    }
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEC2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEEC2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEC2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEC2Ev
42
43
4.82M
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEED2Ev
Line
Count
Source
43
45
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEED2Ev
Line
Count
Source
43
1.66k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEED2Ev
Line
Count
Source
43
45
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEED2Ev
Line
Count
Source
43
2.48k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEED2Ev
Line
Count
Source
43
66.6k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEED2Ev
Line
Count
Source
43
66.7k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEED2Ev
Line
Count
Source
43
121
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEED2Ev
Line
Count
Source
43
4.68M
    virtual ~DummyBrpcCallback() = default;
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEED2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEED2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEED2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEED2Ev
44
45
66.7k
    virtual void call() {}
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEE4callEv
_ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEE4callEv
Line
Count
Source
45
2
    virtual void call() {}
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEE4callEv
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEE4callEv
Line
Count
Source
45
66.7k
    virtual void call() {}
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEE4callEv
46
47
66.8k
    virtual void join() { brpc::Join(call_id_); }
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEE4joinEv
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEE4joinEv
Line
Count
Source
47
66.8k
    virtual void join() { brpc::Join(call_id_); }
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEE4joinEv
48
49
    // according to brpc doc, we MUST save the call_id before rpc done. use this id to join.
50
    // if a rpc is already done then we get the id and join, it's wrong.
51
    brpc::CallId call_id_;
52
    // controller has to be the same lifecycle with the closure, because brpc may use
53
    // it in any stage of the rpc.
54
    std::shared_ptr<brpc::Controller> cntl_;
55
    // We do not know if brpc will use request or response after brpc method returns.
56
    // So that we need keep a shared ptr here to ensure that brpc could use req/rep
57
    // at any stage.
58
    std::shared_ptr<Response> response_;
59
};
60
61
// The closure will be deleted after callback.
62
// It could only be created by using shared ptr or unique ptr.
63
// It will hold a weak ptr of T and call run of T
64
// Callback() {
65
//  xxxx;
66
//  public
67
//  void run() {
68
//      logxxx
69
//  }
70
//  }
71
//
72
//  std::shared_ptr<Callback> b;
73
//
74
//  std::unique_ptr<AutoReleaseClosure> a(b);
75
//  brpc_call(a.release());
76
77
template <typename T>
78
concept HasStatus = requires(T* response) { response->status(); };
79
80
template <typename Request, typename Callback>
81
class AutoReleaseClosure : public google::protobuf::Closure {
82
    using Weak = typename std::shared_ptr<Callback>::weak_type;
83
    using ResponseType = typename Callback::ResponseType;
84
    ENABLE_FACTORY_CREATOR(AutoReleaseClosure);
85
86
public:
87
    AutoReleaseClosure(std::shared_ptr<Request> req, std::shared_ptr<Callback> callback,
88
                       std::weak_ptr<QueryContext> context = {}, std::string_view error_msg = {})
89
4.82M
            : request_(req), callback_(callback), context_(std::move(context)) {
90
4.82M
        this->cntl_ = callback->cntl_;
91
4.82M
        this->response_ = callback->response_;
92
4.82M
    }
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
45
            : request_(req), callback_(callback), context_(std::move(context)) {
90
45
        this->cntl_ = callback->cntl_;
91
45
        this->response_ = callback->response_;
92
45
    }
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
1.66k
            : request_(req), callback_(callback), context_(std::move(context)) {
90
1.66k
        this->cntl_ = callback->cntl_;
91
1.66k
        this->response_ = callback->response_;
92
1.66k
    }
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
45
            : request_(req), callback_(callback), context_(std::move(context)) {
90
45
        this->cntl_ = callback->cntl_;
91
45
        this->response_ = callback->response_;
92
45
    }
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
2.48k
            : request_(req), callback_(callback), context_(std::move(context)) {
90
2.48k
        this->cntl_ = callback->cntl_;
91
2.48k
        this->response_ = callback->response_;
92
2.48k
    }
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
66.5k
            : request_(req), callback_(callback), context_(std::move(context)) {
90
66.5k
        this->cntl_ = callback->cntl_;
91
66.5k
        this->response_ = callback->response_;
92
66.5k
    }
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
68.8k
            : request_(req), callback_(callback), context_(std::move(context)) {
90
68.8k
        this->cntl_ = callback->cntl_;
91
68.8k
        this->response_ = callback->response_;
92
68.8k
    }
_ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
121
            : request_(req), callback_(callback), context_(std::move(context)) {
90
121
        this->cntl_ = callback->cntl_;
91
121
        this->response_ = callback->response_;
92
121
    }
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Line
Count
Source
89
4.68M
            : request_(req), callback_(callback), context_(std::move(context)) {
90
4.68M
        this->cntl_ = callback->cntl_;
91
4.68M
        this->response_ = callback->response_;
92
4.68M
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_ESt8weak_ptrINS_12QueryContextEESt17basic_string_viewIcSt11char_traitsIcEE
93
94
4.78M
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEED2Ev
Line
Count
Source
94
45
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEED2Ev
Line
Count
Source
94
1.66k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEED2Ev
Line
Count
Source
94
45
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEED2Ev
Line
Count
Source
94
2.48k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEED2Ev
Line
Count
Source
94
66.6k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEED2Ev
Line
Count
Source
94
68.8k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEED2Ev
Line
Count
Source
94
120
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEED2Ev
Line
Count
Source
94
4.64M
    ~AutoReleaseClosure() override = default;
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEED2Ev
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEED2Ev
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEED2Ev
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEED2Ev
95
96
    //  Will delete itself
97
4.81M
    void Run() override {
98
4.81M
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
45
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
1.66k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
45
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
2.48k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
66.7k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
68.8k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
120
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
98
4.65M
        Defer defer {[&]() { delete this; }};
Unexecuted instantiation: _ZZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE3RunEvENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE3RunEvENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEE3RunEvENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEE3RunEvENKUlvE_clEv
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
4.81M
        if (auto tmp = callback_.lock()) {
102
4.81M
            tmp->call();
103
4.81M
        }
104
4.81M
        if (cntl_->Failed()) {
105
1
            _process_if_rpc_failed();
106
4.81M
        } else {
107
4.81M
            _process_status<ResponseType>(response_.get());
108
4.81M
        }
109
4.81M
    }
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEE3RunEv
Line
Count
Source
97
45
    void Run() override {
98
45
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
45
        if (auto tmp = callback_.lock()) {
102
0
            tmp->call();
103
0
        }
104
45
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
45
        } else {
107
45
            _process_status<ResponseType>(response_.get());
108
45
        }
109
45
    }
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEE3RunEv
Line
Count
Source
97
1.66k
    void Run() override {
98
1.66k
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
1.66k
        if (auto tmp = callback_.lock()) {
102
0
            tmp->call();
103
0
        }
104
1.66k
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
1.66k
        } else {
107
1.66k
            _process_status<ResponseType>(response_.get());
108
1.66k
        }
109
1.66k
    }
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEE3RunEv
Line
Count
Source
97
45
    void Run() override {
98
45
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
45
        if (auto tmp = callback_.lock()) {
102
0
            tmp->call();
103
0
        }
104
45
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
45
        } else {
107
45
            _process_status<ResponseType>(response_.get());
108
45
        }
109
45
    }
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEE3RunEv
Line
Count
Source
97
2.47k
    void Run() override {
98
2.47k
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
2.47k
        if (auto tmp = callback_.lock()) {
102
2
            tmp->call();
103
2
        }
104
2.47k
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
2.47k
        } else {
107
2.47k
            _process_status<ResponseType>(response_.get());
108
2.47k
        }
109
2.47k
    }
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE3RunEv
Line
Count
Source
97
66.7k
    void Run() override {
98
66.7k
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
66.7k
        if (auto tmp = callback_.lock()) {
102
66.7k
            tmp->call();
103
66.7k
        }
104
66.7k
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
66.7k
        } else {
107
66.7k
            _process_status<ResponseType>(response_.get());
108
66.7k
        }
109
66.7k
    }
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE3RunEv
Line
Count
Source
97
68.8k
    void Run() override {
98
68.8k
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
68.8k
        if (auto tmp = callback_.lock()) {
102
68.8k
            tmp->call();
103
68.8k
        }
104
68.8k
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
68.8k
        } else {
107
68.8k
            _process_status<ResponseType>(response_.get());
108
68.8k
        }
109
68.8k
    }
_ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEE3RunEv
Line
Count
Source
97
121
    void Run() override {
98
121
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
121
        if (auto tmp = callback_.lock()) {
102
0
            tmp->call();
103
0
        }
104
121
        if (cntl_->Failed()) {
105
0
            _process_if_rpc_failed();
106
121
        } else {
107
121
            _process_status<ResponseType>(response_.get());
108
121
        }
109
121
    }
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE3RunEv
Line
Count
Source
97
4.67M
    void Run() override {
98
4.67M
        Defer defer {[&]() { delete this; }};
99
        // If lock failed, it means the callback object is deconstructed, then no need
100
        // to deal with the callback any more.
101
4.67M
        if (auto tmp = callback_.lock()) {
102
4.67M
            tmp->call();
103
4.67M
        }
104
4.67M
        if (cntl_->Failed()) {
105
1
            _process_if_rpc_failed();
106
4.67M
        } else {
107
4.67M
            _process_status<ResponseType>(response_.get());
108
4.67M
        }
109
4.67M
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE3RunEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE3RunEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEE3RunEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEE3RunEv
110
111
    // controller has to be the same lifecycle with the closure, because brpc may use
112
    // it in any stage of the rpc.
113
    std::shared_ptr<brpc::Controller> cntl_;
114
    // We do not know if brpc will use request or response after brpc method returns.
115
    // So that we need keep a shared ptr here to ensure that brpc could use req/rep
116
    // at any stage.
117
    std::shared_ptr<Request> request_;
118
    std::shared_ptr<ResponseType> response_;
119
    std::string error_msg_;
120
121
protected:
122
1
    virtual void _process_if_rpc_failed() {
123
1
        std::string error_msg =
124
1
                fmt::format("RPC meet failed: {} {}", cntl_->ErrorText(), error_msg_);
125
1
        if (auto ctx = context_.lock(); ctx) {
126
0
            ctx->cancel(Status::NetworkError(error_msg));
127
1
        } else {
128
1
            LOG(WARNING) << error_msg;
129
1
        }
130
1
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEE22_process_if_rpc_failedEv
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE22_process_if_rpc_failedEv
Line
Count
Source
122
1
    virtual void _process_if_rpc_failed() {
123
1
        std::string error_msg =
124
1
                fmt::format("RPC meet failed: {} {}", cntl_->ErrorText(), error_msg_);
125
1
        if (auto ctx = context_.lock(); ctx) {
126
0
            ctx->cancel(Status::NetworkError(error_msg));
127
1
        } else {
128
            LOG(WARNING) << error_msg;
129
1
        }
130
1
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEE22_process_if_rpc_failedEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEE22_process_if_rpc_failedEv
131
132
90.2k
    virtual void _process_if_meet_error_status(const Status& status) {
133
90.2k
        if (status.is<ErrorCode::END_OF_FILE>()) {
134
            // no need to log END_OF_FILE, reduce the unlessful log
135
90.2k
            return;
136
90.2k
        }
137
39
        if (auto ctx = context_.lock(); ctx) {
138
0
            ctx->cancel(status);
139
39
        } else {
140
39
            LOG(WARNING) << "RPC meet error status: " << status;
141
39
        }
142
39
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEE29_process_if_meet_error_statusERKNS_6StatusE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEE29_process_if_meet_error_statusERKNS_6StatusE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEE29_process_if_meet_error_statusERKNS_6StatusE
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEE29_process_if_meet_error_statusERKNS_6StatusE
Line
Count
Source
132
4
    virtual void _process_if_meet_error_status(const Status& status) {
133
4
        if (status.is<ErrorCode::END_OF_FILE>()) {
134
            // no need to log END_OF_FILE, reduce the unlessful log
135
4
            return;
136
4
        }
137
0
        if (auto ctx = context_.lock(); ctx) {
138
0
            ctx->cancel(status);
139
0
        } else {
140
            LOG(WARNING) << "RPC meet error status: " << status;
141
0
        }
142
0
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
Line
Count
Source
132
49
    virtual void _process_if_meet_error_status(const Status& status) {
133
49
        if (status.is<ErrorCode::END_OF_FILE>()) {
134
            // no need to log END_OF_FILE, reduce the unlessful log
135
0
            return;
136
0
        }
137
49
        if (auto ctx = context_.lock(); ctx) {
138
0
            ctx->cancel(status);
139
49
        } else {
140
            LOG(WARNING) << "RPC meet error status: " << status;
141
49
        }
142
49
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
Line
Count
Source
132
90.2k
    virtual void _process_if_meet_error_status(const Status& status) {
133
90.2k
        if (status.is<ErrorCode::END_OF_FILE>()) {
134
            // no need to log END_OF_FILE, reduce the unlessful log
135
90.2k
            return;
136
90.2k
        }
137
18.4E
        if (auto ctx = context_.lock(); ctx) {
138
0
            ctx->cancel(status);
139
18.4E
        } else {
140
            LOG(WARNING) << "RPC meet error status: " << status;
141
18.4E
        }
142
18.4E
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEE29_process_if_meet_error_statusERKNS_6StatusE
143
144
private:
145
    template <typename Response>
146
121
    void _process_status(Response* response) {}
147
148
    template <HasStatus Response>
149
4.75M
    void _process_status(Response* response) {
150
4.75M
        if (Status status = Status::create(response->status()); !status.ok()) {
151
90.4k
            _process_if_meet_error_status(status);
152
90.4k
        }
153
4.75M
    }
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
45
    void _process_status(Response* response) {
150
45
        if (Status status = Status::create(response->status()); !status.ok()) {
151
0
            _process_if_meet_error_status(status);
152
0
        }
153
45
    }
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_17DummyBrpcCallbackINS_22PPublishFilterResponseEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
1.65k
    void _process_status(Response* response) {
150
1.65k
        if (Status status = Status::create(response->status()); !status.ok()) {
151
0
            _process_if_meet_error_status(status);
152
0
        }
153
1.65k
    }
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
45
    void _process_status(Response* response) {
150
45
        if (Status status = Status::create(response->status()); !status.ok()) {
151
0
            _process_if_meet_error_status(status);
152
0
        }
153
45
    }
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_17DummyBrpcCallbackINS_20PMergeFilterResponseEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
2.47k
    void _process_status(Response* response) {
150
2.47k
        if (Status status = Status::create(response->status()); !status.ok()) {
151
4
            _process_if_meet_error_status(status);
152
4
        }
153
2.47k
    }
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
66.6k
    void _process_status(Response* response) {
150
66.6k
        if (Status status = Status::create(response->status()); !status.ok()) {
151
0
            _process_if_meet_error_status(status);
152
0
        }
153
66.6k
    }
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
68.6k
    void _process_status(Response* response) {
150
68.6k
        if (Status status = Status::create(response->status()); !status.ok()) {
151
49
            _process_if_meet_error_status(status);
152
49
        }
153
68.6k
    }
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Line
Count
Source
149
4.61M
    void _process_status(Response* response) {
150
4.61M
        if (Status status = Status::create(response->status()); !status.ok()) {
151
90.3k
            _process_if_meet_error_status(status);
152
90.3k
        }
153
4.61M
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_28PTabletWriteSlaveDoneRequestENS_17DummyBrpcCallbackINS_27PTabletWriteSlaveDoneResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_24PTabletWriteSlaveRequestENS_17DummyBrpcCallbackINS_23PTabletWriteSlaveResultEEEE15_process_statusITkNS_9HasStatusES3_EEvPT_
154
    // Use a weak ptr to keep the callback, so that the callback can be deleted if the main
155
    // thread is freed.
156
    Weak callback_;
157
    std::weak_ptr<QueryContext> context_;
158
};
159
160
} // namespace doris