Coverage Report

Created: 2026-11-04 06:02

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