Coverage Report

Created: 2026-10-16 11:43

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 <type_traits>
23
#include <utility>
24
25
#include "common/query_log_context.h"
26
#include "runtime/query_context.h"
27
#include "runtime/thread_context.h"
28
#include "service/brpc.h" // IWYU pragma: keep
29
30
namespace doris {
31
32
template <typename T>
33
concept HasStatus = requires(T* response) { response->status(); };
34
35
template <typename Response>
36
class DummyBrpcCallback {
37
    ENABLE_FACTORY_CREATOR(DummyBrpcCallback);
38
39
public:
40
    using ResponseType = Response;
41
856k
    DummyBrpcCallback() {
42
856k
        cntl_ = std::make_shared<brpc::Controller>();
43
856k
        call_id_ = cntl_->call_id();
44
856k
        response_ = std::make_shared<Response>();
45
856k
    }
_ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEEC2Ev
Line
Count
Source
41
2.71k
    DummyBrpcCallback() {
42
2.71k
        cntl_ = std::make_shared<brpc::Controller>();
43
2.71k
        call_id_ = cntl_->call_id();
44
2.71k
        response_ = std::make_shared<Response>();
45
2.71k
    }
_ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEEC2Ev
Line
Count
Source
41
49.0k
    DummyBrpcCallback() {
42
49.0k
        cntl_ = std::make_shared<brpc::Controller>();
43
49.0k
        call_id_ = cntl_->call_id();
44
49.0k
        response_ = std::make_shared<Response>();
45
49.0k
    }
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEC2Ev
Line
Count
Source
41
47.8k
    DummyBrpcCallback() {
42
47.8k
        cntl_ = std::make_shared<brpc::Controller>();
43
47.8k
        call_id_ = cntl_->call_id();
44
47.8k
        response_ = std::make_shared<Response>();
45
47.8k
    }
_ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEC2Ev
Line
Count
Source
41
112
    DummyBrpcCallback() {
42
112
        cntl_ = std::make_shared<brpc::Controller>();
43
112
        call_id_ = cntl_->call_id();
44
112
        response_ = std::make_shared<Response>();
45
112
    }
_ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEEC2Ev
Line
Count
Source
41
2.10k
    DummyBrpcCallback() {
42
2.10k
        cntl_ = std::make_shared<brpc::Controller>();
43
2.10k
        call_id_ = cntl_->call_id();
44
2.10k
        response_ = std::make_shared<Response>();
45
2.10k
    }
_ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEEC2Ev
Line
Count
Source
41
64
    DummyBrpcCallback() {
42
64
        cntl_ = std::make_shared<brpc::Controller>();
43
64
        call_id_ = cntl_->call_id();
44
64
        response_ = std::make_shared<Response>();
45
64
    }
_ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEEC2Ev
Line
Count
Source
41
72
    DummyBrpcCallback() {
42
72
        cntl_ = std::make_shared<brpc::Controller>();
43
72
        call_id_ = cntl_->call_id();
44
72
        response_ = std::make_shared<Response>();
45
72
    }
_ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEEC2Ev
Line
Count
Source
41
754k
    DummyBrpcCallback() {
42
754k
        cntl_ = std::make_shared<brpc::Controller>();
43
754k
        call_id_ = cntl_->call_id();
44
754k
        response_ = std::make_shared<Response>();
45
754k
    }
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEC2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEEC2Ev
46
47
866k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEED2Ev
Line
Count
Source
47
2.71k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEED2Ev
Line
Count
Source
47
49.1k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEED2Ev
Line
Count
Source
47
49.1k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEED2Ev
Line
Count
Source
47
111
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEED2Ev
Line
Count
Source
47
2.10k
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEED2Ev
Line
Count
Source
47
64
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEED2Ev
Line
Count
Source
47
72
    virtual ~DummyBrpcCallback() = default;
_ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEED2Ev
Line
Count
Source
47
763k
    virtual ~DummyBrpcCallback() = default;
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEED2Ev
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEED2Ev
48
49
49.4k
    virtual void call() {}
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEE4callEv
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEE4callEv
Line
Count
Source
49
49.4k
    virtual void call() {}
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEE4callEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEE4callEv
50
51
49.3k
    virtual void join() { brpc::Join(call_id_); }
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_19PTransmitDataResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_20PMergeFilterResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSendFilterSizeResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_27PTabletWriterAddBlockResultEE4joinEv
_ZN5doris17DummyBrpcCallbackINS_23PTabletWriterOpenResultEE4joinEv
Line
Count
Source
51
49.3k
    virtual void join() { brpc::Join(call_id_); }
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_25PTabletWriterCancelResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_22PPublishFilterResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_23PSyncFilterSizeResponseEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEE4joinEv
Unexecuted instantiation: _ZN5doris17DummyBrpcCallbackINS_21PFetchArrowDataResultEE4joinEv
52
53
    // according to brpc doc, we MUST save the call_id before rpc done. use this id to join.
54
    // if a rpc is already done then we get the id and join, it's wrong.
55
    brpc::CallId call_id_;
56
    // controller has to be the same lifecycle with the closure, because brpc may use
57
    // it in any stage of the rpc.
58
    std::shared_ptr<brpc::Controller> cntl_;
59
    // We do not know if brpc will use request or response after brpc method returns.
60
    // So that we need keep a shared ptr here to ensure that brpc could use req/rep
61
    // at any stage.
62
    std::shared_ptr<Response> response_;
63
};
64
65
template <typename Response>
66
class HandleErrorBrpcCallback : public DummyBrpcCallback<Response> {
67
    ENABLE_FACTORY_CREATOR(HandleErrorBrpcCallback);
68
69
public:
70
    using ResponseType = Response;
71
    // input context must be held by caller
72
    HandleErrorBrpcCallback(std::weak_ptr<QueryContext> context = {})
73
4.87k
            : _context(std::move(context)) {}
_ZN5doris23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEEC2ESt8weak_ptrINS_12QueryContextEE
Line
Count
Source
73
2.70k
            : _context(std::move(context)) {}
_ZN5doris23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEEC2ESt8weak_ptrINS_12QueryContextEE
Line
Count
Source
73
2.10k
            : _context(std::move(context)) {}
_ZN5doris23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEEC2ESt8weak_ptrINS_12QueryContextEE
Line
Count
Source
73
64
            : _context(std::move(context)) {}
74
75
4.87k
    ~HandleErrorBrpcCallback() override = default;
_ZN5doris23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEED2Ev
Line
Count
Source
75
2.70k
    ~HandleErrorBrpcCallback() override = default;
_ZN5doris23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEED2Ev
Line
Count
Source
75
2.10k
    ~HandleErrorBrpcCallback() override = default;
_ZN5doris23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEED2Ev
Line
Count
Source
75
64
    ~HandleErrorBrpcCallback() override = default;
76
77
4.87k
    void call() override {
78
4.87k
        if (this->cntl_->Failed()) {
79
3
            LOG(WARNING) << fmt::format("RPC meet failed: {}", this->cntl_->ErrorText());
80
3
            if (auto ctx = _context.lock()) {
81
1
                ctx->cancel(Status::NetworkError("RPC meet failed: {}", this->cntl_->ErrorText()));
82
1
            }
83
3
            return;
84
3
        }
85
4.86k
        if constexpr (HasStatus<Response>) {
86
4.86k
            if (Status status = Status::create(this->response_->status()); !status.ok()) {
87
9
                if (!status.is<ErrorCode::END_OF_FILE>()) {
88
2
                    LOG(WARNING) << "RPC meet error status: " << status;
89
2
                    if (auto ctx = _context.lock()) {
90
1
                        ctx->cancel(std::move(status));
91
1
                    }
92
2
                }
93
9
            }
94
4.86k
        }
95
4.86k
    }
_ZN5doris23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEE4callEv
Line
Count
Source
77
2.70k
    void call() override {
78
2.70k
        if (this->cntl_->Failed()) {
79
3
            LOG(WARNING) << fmt::format("RPC meet failed: {}", this->cntl_->ErrorText());
80
3
            if (auto ctx = _context.lock()) {
81
1
                ctx->cancel(Status::NetworkError("RPC meet failed: {}", this->cntl_->ErrorText()));
82
1
            }
83
3
            return;
84
3
        }
85
2.70k
        if constexpr (HasStatus<Response>) {
86
2.70k
            if (Status status = Status::create(this->response_->status()); !status.ok()) {
87
9
                if (!status.is<ErrorCode::END_OF_FILE>()) {
88
2
                    LOG(WARNING) << "RPC meet error status: " << status;
89
2
                    if (auto ctx = _context.lock()) {
90
1
                        ctx->cancel(std::move(status));
91
1
                    }
92
2
                }
93
9
            }
94
2.70k
        }
95
2.70k
    }
_ZN5doris23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEE4callEv
Line
Count
Source
77
2.10k
    void call() override {
78
2.10k
        if (this->cntl_->Failed()) {
79
0
            LOG(WARNING) << fmt::format("RPC meet failed: {}", this->cntl_->ErrorText());
80
0
            if (auto ctx = _context.lock()) {
81
0
                ctx->cancel(Status::NetworkError("RPC meet failed: {}", this->cntl_->ErrorText()));
82
0
            }
83
0
            return;
84
0
        }
85
2.10k
        if constexpr (HasStatus<Response>) {
86
2.10k
            if (Status status = Status::create(this->response_->status()); !status.ok()) {
87
0
                if (!status.is<ErrorCode::END_OF_FILE>()) {
88
0
                    LOG(WARNING) << "RPC meet error status: " << status;
89
0
                    if (auto ctx = _context.lock()) {
90
0
                        ctx->cancel(std::move(status));
91
0
                    }
92
0
                }
93
0
            }
94
2.10k
        }
95
2.10k
    }
_ZN5doris23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEE4callEv
Line
Count
Source
77
64
    void call() override {
78
64
        if (this->cntl_->Failed()) {
79
0
            LOG(WARNING) << fmt::format("RPC meet failed: {}", this->cntl_->ErrorText());
80
0
            if (auto ctx = _context.lock()) {
81
0
                ctx->cancel(Status::NetworkError("RPC meet failed: {}", this->cntl_->ErrorText()));
82
0
            }
83
0
            return;
84
0
        }
85
64
        if constexpr (HasStatus<Response>) {
86
64
            if (Status status = Status::create(this->response_->status()); !status.ok()) {
87
0
                if (!status.is<ErrorCode::END_OF_FILE>()) {
88
0
                    LOG(WARNING) << "RPC meet error status: " << status;
89
0
                    if (auto ctx = _context.lock()) {
90
0
                        ctx->cancel(std::move(status));
91
0
                    }
92
0
                }
93
0
            }
94
64
        }
95
64
    }
96
97
private:
98
    std::weak_ptr<QueryContext> _context;
99
};
100
101
// The closure will be deleted after callback.
102
// It could only be created by using shared ptr or unique ptr.
103
// Example:
104
//  std::unique_ptr<AutoReleaseClosure> a(b);
105
//  brpc_call(a.release());
106
// The closure does not own the callback, so the callback MUST be kept alive by its external owner
107
// while its result is still needed. A callback may indirectly retain large query-scoped objects,
108
// such as QueryContext and operator state. Holding it strongly from an in-flight RPC would extend
109
// all of those objects' lifetimes until the RPC finishes, preventing a cancelled query from
110
// releasing its memory promptly.
111
//
112
// Keep only a weak reference here. If query cancellation or teardown destroys the external owner
113
// before a late RPC completion arrives, Run() still releases the request/controller/response owned
114
// by this closure, but skips callback business logic because that query no longer needs the result.
115
template <typename Request, typename Callback>
116
class AutoReleaseClosure : public google::protobuf::Closure {
117
    using ResponseType = typename Callback::ResponseType;
118
    ENABLE_FACTORY_CREATOR(AutoReleaseClosure);
119
120
public:
121
    AutoReleaseClosure(std::shared_ptr<Request> req, std::shared_ptr<Callback> callback)
122
871k
            : request_(std::move(req)),
123
871k
              callback_(callback),
124
871k
              query_log_identity_(current_query_log_identity()) {
125
871k
        this->cntl_ = callback->cntl_;
126
871k
        this->response_ = callback->response_;
127
871k
    }
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
2.70k
            : request_(std::move(req)),
123
2.70k
              callback_(callback),
124
2.70k
              query_log_identity_(current_query_log_identity()) {
125
2.70k
        this->cntl_ = callback->cntl_;
126
2.70k
        this->response_ = callback->response_;
127
2.70k
    }
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
49.0k
            : request_(std::move(req)),
123
49.0k
              callback_(callback),
124
49.0k
              query_log_identity_(current_query_log_identity()) {
125
49.0k
        this->cntl_ = callback->cntl_;
126
49.0k
        this->response_ = callback->response_;
127
49.0k
    }
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
55.7k
            : request_(std::move(req)),
123
55.7k
              callback_(callback),
124
55.7k
              query_log_identity_(current_query_log_identity()) {
125
55.7k
        this->cntl_ = callback->cntl_;
126
55.7k
        this->response_ = callback->response_;
127
55.7k
    }
_ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
112
            : request_(std::move(req)),
123
112
              callback_(callback),
124
112
              query_log_identity_(current_query_log_identity()) {
125
112
        this->cntl_ = callback->cntl_;
126
112
        this->response_ = callback->response_;
127
112
    }
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
64
            : request_(std::move(req)),
123
64
              callback_(callback),
124
64
              query_log_identity_(current_query_log_identity()) {
125
64
        this->cntl_ = callback->cntl_;
126
64
        this->response_ = callback->response_;
127
64
    }
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
2.10k
            : request_(std::move(req)),
123
2.10k
              callback_(callback),
124
2.10k
              query_log_identity_(current_query_log_identity()) {
125
2.10k
        this->cntl_ = callback->cntl_;
126
2.10k
        this->response_ = callback->response_;
127
2.10k
    }
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_16SyncSizeCallbackEEC2ESt10shared_ptrIS1_ES4_IS2_E
Line
Count
Source
122
65
            : request_(std::move(req)),
123
65
              callback_(callback),
124
65
              query_log_identity_(current_query_log_identity()) {
125
65
        this->cntl_ = callback->cntl_;
126
65
        this->response_ = callback->response_;
127
65
    }
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Line
Count
Source
122
751k
            : request_(std::move(req)),
123
751k
              callback_(callback),
124
751k
              query_log_identity_(current_query_log_identity()) {
125
751k
        this->cntl_ = callback->cntl_;
126
751k
        this->response_ = callback->response_;
127
751k
    }
_ZN5doris18AutoReleaseClosureIN4brpc17SerializedRequestENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEEC2ESt10shared_ptrIS2_ES7_IS5_E
Line
Count
Source
122
10.2k
            : request_(std::move(req)),
123
10.2k
              callback_(callback),
124
10.2k
              query_log_identity_(current_query_log_identity()) {
125
10.2k
        this->cntl_ = callback->cntl_;
126
10.2k
        this->response_ = callback->response_;
127
10.2k
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEEC2ESt10shared_ptrIS1_ES6_IS4_E
128
129
870k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEEEED2Ev
Line
Count
Source
129
2.70k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEED2Ev
Line
Count
Source
129
49.3k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEED2Ev
Line
Count
Source
129
55.7k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEED2Ev
Line
Count
Source
129
112
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEEEED2Ev
Line
Count
Source
129
64
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEEEED2Ev
Line
Count
Source
129
2.10k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_16SyncSizeCallbackEED2Ev
Line
Count
Source
129
65
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEED2Ev
Line
Count
Source
129
750k
    ~AutoReleaseClosure() override = default;
_ZN5doris18AutoReleaseClosureIN4brpc17SerializedRequestENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEED2Ev
Line
Count
Source
129
10.3k
    ~AutoReleaseClosure() override = default;
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEED2Ev
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEED2Ev
130
131
    // Releases per-RPC resources, invokes the callback if it is still alive, and then deletes itself.
132
868k
    void Run() override {
133
868k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
871k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
2.70k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
49.4k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
55.7k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
112
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
64
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
2.10k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_16SyncSizeCallbackEE3RunEvENKUlvE_clEv
Line
Count
Source
134
65
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
751k
        Defer defer {[&]() { delete this; }};
_ZZN5doris18AutoReleaseClosureIN4brpc17SerializedRequestENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE3RunEvENKUlvE_clEv
Line
Count
Source
134
10.3k
        Defer defer {[&]() { delete this; }};
Unexecuted instantiation: _ZZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE3RunEvENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE3RunEvENKUlvE_clEv
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
868k
        cntl_->request_attachment().clear();
146
147
871k
        if (auto tmp = callback_.lock()) {
148
871k
            tmp->call();
149
871k
        }
150
868k
    }
_ZN5doris18AutoReleaseClosureINS_19PMergeFilterRequestENS_23HandleErrorBrpcCallbackINS_20PMergeFilterResponseEEEE3RunEv
Line
Count
Source
132
2.69k
    void Run() override {
133
2.69k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
2.69k
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
2.69k
        cntl_->request_attachment().clear();
146
147
2.70k
        if (auto tmp = callback_.lock()) {
148
2.70k
            tmp->call();
149
2.70k
        }
150
2.69k
    }
_ZN5doris18AutoReleaseClosureINS_24PTabletWriterOpenRequestENS_17DummyBrpcCallbackINS_23PTabletWriterOpenResultEEEE3RunEv
Line
Count
Source
132
49.3k
    void Run() override {
133
49.3k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
49.3k
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
49.3k
        cntl_->request_attachment().clear();
146
147
49.4k
        if (auto tmp = callback_.lock()) {
148
49.4k
            tmp->call();
149
49.4k
        }
150
49.3k
    }
_ZN5doris18AutoReleaseClosureINS_28PTabletWriterAddBlockRequestENS_18WriteBlockCallbackINS_27PTabletWriterAddBlockResultEEEE3RunEv
Line
Count
Source
132
55.6k
    void Run() override {
133
55.6k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
55.6k
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
55.6k
        cntl_->request_attachment().clear();
146
147
55.7k
        if (auto tmp = callback_.lock()) {
148
55.7k
            tmp->call();
149
55.7k
        }
150
55.6k
    }
_ZN5doris18AutoReleaseClosureINS_26PTabletWriterCancelRequestENS_17DummyBrpcCallbackINS_25PTabletWriterCancelResultEEEE3RunEv
Line
Count
Source
132
112
    void Run() override {
133
112
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
112
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
112
        cntl_->request_attachment().clear();
146
147
112
        if (auto tmp = callback_.lock()) {
148
0
            tmp->call();
149
0
        }
150
112
    }
_ZN5doris18AutoReleaseClosureINS_22PSyncFilterSizeRequestENS_23HandleErrorBrpcCallbackINS_23PSyncFilterSizeResponseEEEE3RunEv
Line
Count
Source
132
64
    void Run() override {
133
64
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
64
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
64
        cntl_->request_attachment().clear();
146
147
64
        if (auto tmp = callback_.lock()) {
148
64
            tmp->call();
149
64
        }
150
64
    }
_ZN5doris18AutoReleaseClosureINS_23PPublishFilterRequestV2ENS_23HandleErrorBrpcCallbackINS_22PPublishFilterResponseEEEE3RunEv
Line
Count
Source
132
2.10k
    void Run() override {
133
2.10k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
2.10k
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
2.10k
        cntl_->request_attachment().clear();
146
147
2.10k
        if (auto tmp = callback_.lock()) {
148
2.10k
            tmp->call();
149
2.10k
        }
150
2.10k
    }
_ZN5doris18AutoReleaseClosureINS_22PSendFilterSizeRequestENS_16SyncSizeCallbackEE3RunEv
Line
Count
Source
132
65
    void Run() override {
133
65
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
65
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
65
        cntl_->request_attachment().clear();
146
147
65
        if (auto tmp = callback_.lock()) {
148
64
            tmp->call();
149
64
        }
150
65
    }
_ZN5doris18AutoReleaseClosureINS_19PTransmitDataParamsENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE3RunEv
Line
Count
Source
132
748k
    void Run() override {
133
748k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
748k
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
748k
        cntl_->request_attachment().clear();
146
147
751k
        if (auto tmp = callback_.lock()) {
148
751k
            tmp->call();
149
751k
        }
150
748k
    }
_ZN5doris18AutoReleaseClosureIN4brpc17SerializedRequestENS_20ExchangeSendCallbackINS_19PTransmitDataResultEEEE3RunEv
Line
Count
Source
132
10.2k
    void Run() override {
133
10.2k
        ScopedQueryLogContext query_log_scope(query_log_identity_);
134
10.2k
        Defer defer {[&]() { delete this; }};
135
136
        // The request attachment is no longer needed after brpc finishes the RPC. It can contain a
137
        // large serialized runtime filter, especially a Bloom filter. Since the callback owner may
138
        // retain cntl_ after this closure is deleted (and some callbacks may also reuse it), keeping
139
        // the attachment here would retain that memory until the next Controller::Reset() or until
140
        // the callback is destroyed.
141
        //
142
        // This must be cleared before call(): a callback may synchronously start the next RPC and
143
        // reuse the same Controller, in which case clearing it after call() could erase the new
144
        // RPC's request attachment.
145
10.2k
        cntl_->request_attachment().clear();
146
147
10.2k
        if (auto tmp = callback_.lock()) {
148
10.2k
            tmp->call();
149
10.2k
        }
150
10.2k
    }
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_30PFetchArrowFlightSchemaRequestENS_17DummyBrpcCallbackINS_29PFetchArrowFlightSchemaResultEEEE3RunEv
Unexecuted instantiation: _ZN5doris18AutoReleaseClosureINS_22PFetchArrowDataRequestENS_17DummyBrpcCallbackINS_21PFetchArrowDataResultEEEE3RunEv
151
152
    // controller has to be the same lifecycle with the closure, because brpc may use
153
    // it in any stage of the rpc.
154
    std::shared_ptr<brpc::Controller> cntl_;
155
    // We do not know if brpc will use request or response after brpc method returns.
156
    // So that we need keep a shared ptr here to ensure that brpc could use req/rep
157
    // at any stage.
158
    std::shared_ptr<Request> request_;
159
    std::shared_ptr<ResponseType> response_;
160
161
private:
162
    std::weak_ptr<Callback> callback_;
163
    const QueryLogIdentity query_log_identity_;
164
};
165
166
} // namespace doris