Coverage Report

Created: 2025-03-10 18:45

/root/doris/be/src/runtime/runtime_state.cpp
Line
Count
Source (jump to first uncovered line)
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
// This file is copied from
18
// https://github.com/apache/impala/blob/branch-2.9.0/be/src/runtime/runtime-state.cpp
19
// and modified by Doris
20
21
#include "runtime/runtime_state.h"
22
23
#include <fmt/format.h>
24
#include <gen_cpp/PaloInternalService_types.h>
25
#include <gen_cpp/Types_types.h>
26
#include <glog/logging.h>
27
28
#include <fstream>
29
#include <memory>
30
#include <string>
31
32
#include "cloud/cloud_storage_engine.h"
33
#include "cloud/config.h"
34
#include "common/config.h"
35
#include "common/logging.h"
36
#include "common/object_pool.h"
37
#include "common/status.h"
38
#include "io/fs/s3_file_system.h"
39
#include "olap/storage_engine.h"
40
#include "pipeline/exec/operator.h"
41
#include "pipeline/pipeline_task.h"
42
#include "runtime/exec_env.h"
43
#include "runtime/fragment_mgr.h"
44
#include "runtime/load_path_mgr.h"
45
#include "runtime/memory/mem_tracker_limiter.h"
46
#include "runtime/memory/thread_mem_tracker_mgr.h"
47
#include "runtime/query_context.h"
48
#include "runtime/runtime_filter_mgr.h"
49
#include "runtime/thread_context.h"
50
#include "util/timezone_utils.h"
51
#include "util/uid_util.h"
52
#include "vec/runtime/vdatetime_value.h"
53
54
namespace doris {
55
#include "common/compile_check_begin.h"
56
using namespace ErrorCode;
57
58
RuntimeState::RuntimeState(const TPlanFragmentExecParams& fragment_exec_params,
59
                           const TQueryOptions& query_options, const TQueryGlobals& query_globals,
60
                           ExecEnv* exec_env, QueryContext* ctx,
61
                           const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker)
62
        : _profile("Fragment " + print_id(fragment_exec_params.fragment_instance_id)),
63
          _load_channel_profile("<unnamed>"),
64
          _obj_pool(new ObjectPool()),
65
          _unreported_error_idx(0),
66
          _query_id(fragment_exec_params.query_id),
67
          _per_fragment_instance_idx(0),
68
          _num_rows_load_total(0),
69
          _num_rows_load_filtered(0),
70
          _num_rows_load_unselected(0),
71
          _num_print_error_rows(0),
72
          _num_bytes_load_total(0),
73
          _num_finished_scan_range(0),
74
          _error_row_number(0),
75
0
          _query_ctx(ctx) {
76
0
    Status status =
77
0
            init(fragment_exec_params.fragment_instance_id, query_options, query_globals, exec_env);
78
0
    DCHECK(status.ok());
79
0
    if (query_mem_tracker != nullptr) {
80
0
        _query_mem_tracker = query_mem_tracker;
81
0
    } else {
82
0
        DCHECK(ctx != nullptr);
83
0
        _query_mem_tracker = ctx->query_mem_tracker();
84
0
    }
85
0
#ifdef BE_TEST
86
0
    if (_query_mem_tracker == nullptr) {
87
0
        init_mem_trackers();
88
0
    }
89
0
#endif
90
0
    DCHECK(_query_mem_tracker != nullptr && _query_mem_tracker->label() != "Orphan");
91
0
    if (fragment_exec_params.__isset.runtime_filter_params) {
92
0
        _query_ctx->runtime_filter_mgr()->set_runtime_filter_params(
93
0
                fragment_exec_params.runtime_filter_params);
94
0
    }
95
0
}
96
97
RuntimeState::RuntimeState(const TUniqueId& instance_id, const TUniqueId& query_id,
98
                           int32_t fragment_id, const TQueryOptions& query_options,
99
                           const TQueryGlobals& query_globals, ExecEnv* exec_env, QueryContext* ctx)
100
        : _profile("Fragment " + print_id(instance_id)),
101
          _load_channel_profile("<unnamed>"),
102
          _obj_pool(new ObjectPool()),
103
          _unreported_error_idx(0),
104
          _query_id(query_id),
105
          _fragment_id(fragment_id),
106
          _per_fragment_instance_idx(0),
107
          _num_rows_load_total(0),
108
          _num_rows_load_filtered(0),
109
          _num_rows_load_unselected(0),
110
          _num_rows_filtered_in_strict_mode_partial_update(0),
111
          _num_print_error_rows(0),
112
          _num_bytes_load_total(0),
113
          _num_finished_scan_range(0),
114
          _error_row_number(0),
115
20
          _query_ctx(ctx) {
116
20
    [[maybe_unused]] auto status = init(instance_id, query_options, query_globals, exec_env);
117
20
    DCHECK(status.ok());
118
20
    _query_mem_tracker = ctx->query_mem_tracker();
119
20
#ifdef BE_TEST
120
20
    if (_query_mem_tracker == nullptr) {
121
0
        init_mem_trackers();
122
0
    }
123
20
#endif
124
20
    DCHECK(_query_mem_tracker != nullptr && _query_mem_tracker->label() != "Orphan");
125
20
}
126
127
RuntimeState::RuntimeState(const TUniqueId& query_id, int32_t fragment_id,
128
                           const TQueryOptions& query_options, const TQueryGlobals& query_globals,
129
                           ExecEnv* exec_env, QueryContext* ctx)
130
        : _profile("PipelineX  " + std::to_string(fragment_id)),
131
          _load_channel_profile("<unnamed>"),
132
          _obj_pool(new ObjectPool()),
133
          _unreported_error_idx(0),
134
          _query_id(query_id),
135
          _fragment_id(fragment_id),
136
          _per_fragment_instance_idx(0),
137
          _num_rows_load_total(0),
138
          _num_rows_load_filtered(0),
139
          _num_rows_load_unselected(0),
140
          _num_rows_filtered_in_strict_mode_partial_update(0),
141
          _num_print_error_rows(0),
142
          _num_bytes_load_total(0),
143
          _num_finished_scan_range(0),
144
          _error_row_number(0),
145
11
          _query_ctx(ctx) {
146
    // TODO: do we really need instance id?
147
11
    Status status = init(TUniqueId(), query_options, query_globals, exec_env);
148
11
    DCHECK(status.ok());
149
11
    _query_mem_tracker = ctx->query_mem_tracker();
150
11
#ifdef BE_TEST
151
11
    if (_query_mem_tracker == nullptr) {
152
0
        init_mem_trackers();
153
0
    }
154
11
#endif
155
11
    DCHECK(_query_mem_tracker != nullptr && _query_mem_tracker->label() != "Orphan");
156
11
}
157
158
RuntimeState::RuntimeState(const TQueryGlobals& query_globals)
159
        : _profile("<unnamed>"),
160
          _load_channel_profile("<unnamed>"),
161
          _obj_pool(new ObjectPool()),
162
          _unreported_error_idx(0),
163
11.0k
          _per_fragment_instance_idx(0) {
164
11.0k
    _query_options.batch_size = DEFAULT_BATCH_SIZE;
165
11.0k
    if (query_globals.__isset.time_zone && query_globals.__isset.nano_seconds) {
166
0
        _timezone = query_globals.time_zone;
167
0
        _timestamp_ms = query_globals.timestamp_ms;
168
0
        _nano_seconds = query_globals.nano_seconds;
169
11.0k
    } else if (query_globals.__isset.time_zone) {
170
11.0k
        _timezone = query_globals.time_zone;
171
11.0k
        _timestamp_ms = query_globals.timestamp_ms;
172
11.0k
        _nano_seconds = 0;
173
11.0k
    } else if (!query_globals.now_string.empty()) {
174
0
        _timezone = TimezoneUtils::default_time_zone;
175
0
        VecDateTimeValue dt;
176
0
        dt.from_date_str(query_globals.now_string.c_str(), query_globals.now_string.size());
177
0
        int64_t timestamp;
178
0
        dt.unix_timestamp(&timestamp, _timezone);
179
0
        _timestamp_ms = timestamp * 1000;
180
0
        _nano_seconds = 0;
181
15
    } else {
182
        //Unit test may set into here
183
15
        _timezone = TimezoneUtils::default_time_zone;
184
15
        _timestamp_ms = 0;
185
15
        _nano_seconds = 0;
186
15
    }
187
11.0k
    TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj);
188
11.0k
    init_mem_trackers("<unnamed>");
189
11.0k
}
190
191
RuntimeState::RuntimeState()
192
        : _profile("<unnamed>"),
193
          _load_channel_profile("<unnamed>"),
194
          _obj_pool(new ObjectPool()),
195
          _unreported_error_idx(0),
196
160
          _per_fragment_instance_idx(0) {
197
160
    _query_options.batch_size = DEFAULT_BATCH_SIZE;
198
160
    _query_options.be_exec_version = BeExecVersionManager::get_newest_version();
199
160
    _timezone = TimezoneUtils::default_time_zone;
200
160
    _timestamp_ms = 0;
201
160
    _nano_seconds = 0;
202
160
    TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj);
203
160
    _exec_env = ExecEnv::GetInstance();
204
160
    init_mem_trackers("<unnamed>");
205
160
}
206
207
11.2k
RuntimeState::~RuntimeState() {
208
11.2k
    SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_query_mem_tracker);
209
    // close error log file
210
11.2k
    if (_error_log_file != nullptr && _error_log_file->is_open()) {
211
0
        _error_log_file->close();
212
0
    }
213
214
11.2k
    _obj_pool->clear();
215
11.2k
}
216
217
Status RuntimeState::init(const TUniqueId& fragment_instance_id, const TQueryOptions& query_options,
218
35
                          const TQueryGlobals& query_globals, ExecEnv* exec_env) {
219
35
    _fragment_instance_id = fragment_instance_id;
220
35
    _query_options = query_options;
221
35
    if (query_globals.__isset.time_zone && query_globals.__isset.nano_seconds) {
222
0
        _timezone = query_globals.time_zone;
223
0
        _timestamp_ms = query_globals.timestamp_ms;
224
0
        _nano_seconds = query_globals.nano_seconds;
225
35
    } else if (query_globals.__isset.time_zone) {
226
0
        _timezone = query_globals.time_zone;
227
0
        _timestamp_ms = query_globals.timestamp_ms;
228
0
        _nano_seconds = 0;
229
35
    } else if (!query_globals.now_string.empty()) {
230
0
        _timezone = TimezoneUtils::default_time_zone;
231
0
        VecDateTimeValue dt;
232
0
        dt.from_date_str(query_globals.now_string.c_str(), query_globals.now_string.size());
233
0
        int64_t timestamp;
234
0
        dt.unix_timestamp(&timestamp, _timezone);
235
0
        _timestamp_ms = timestamp * 1000;
236
0
        _nano_seconds = 0;
237
35
    } else {
238
        //Unit test may set into here
239
35
        _timezone = TimezoneUtils::default_time_zone;
240
35
        _timestamp_ms = 0;
241
35
        _nano_seconds = 0;
242
35
    }
243
35
    TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj);
244
245
35
    if (query_globals.__isset.load_zero_tolerance) {
246
35
        _load_zero_tolerance = query_globals.load_zero_tolerance;
247
35
    }
248
249
35
    _exec_env = exec_env;
250
251
35
    if (_query_options.max_errors <= 0) {
252
        // TODO: fix linker error and uncomment this
253
        //_query_options.max_errors = config::max_errors;
254
35
        _query_options.max_errors = 100;
255
35
    }
256
257
35
    if (_query_options.batch_size <= 0) {
258
22
        _query_options.batch_size = DEFAULT_BATCH_SIZE;
259
22
    }
260
261
35
    _db_name = "insert_stmt";
262
35
    _import_label = print_id(fragment_instance_id);
263
264
35
    _profile_level = query_options.__isset.profile_level ? query_options.profile_level : 2;
265
266
35
    return Status::OK();
267
35
}
268
269
0
std::weak_ptr<QueryContext> RuntimeState::get_query_ctx_weak() {
270
0
    return _exec_env->fragment_mgr()->get_query_ctx(_query_ctx->query_id());
271
0
}
272
273
11.2k
void RuntimeState::init_mem_trackers(const std::string& name, const TUniqueId& id) {
274
11.2k
    _query_mem_tracker = MemTrackerLimiter::create_shared(
275
11.2k
            MemTrackerLimiter::Type::OTHER, fmt::format("{}#Id={}", name, print_id(id)));
276
11.2k
}
277
278
0
std::shared_ptr<MemTrackerLimiter> RuntimeState::query_mem_tracker() const {
279
0
    CHECK(_query_mem_tracker != nullptr);
280
0
    return _query_mem_tracker;
281
0
}
282
283
0
WorkloadGroupPtr RuntimeState::workload_group() {
284
0
    return _query_ctx->workload_group();
285
0
}
286
287
0
bool RuntimeState::log_error(const std::string& error) {
288
0
    std::lock_guard<std::mutex> l(_error_log_lock);
289
290
0
    if (_error_log.size() < _query_options.max_errors) {
291
0
        _error_log.push_back(error);
292
0
        return true;
293
0
    }
294
295
0
    return false;
296
0
}
297
298
0
void RuntimeState::get_unreported_errors(std::vector<std::string>* new_errors) {
299
0
    std::lock_guard<std::mutex> l(_error_log_lock);
300
301
0
    if (_unreported_error_idx < _error_log.size()) {
302
0
        new_errors->assign(_error_log.begin() + _unreported_error_idx, _error_log.end());
303
0
        _unreported_error_idx = (int)_error_log.size();
304
0
    }
305
0
}
306
307
63
bool RuntimeState::is_cancelled() const {
308
    // Maybe we should just return _is_cancelled.load()
309
63
    return !_exec_status.ok() || (_query_ctx && _query_ctx->is_cancelled());
310
63
}
311
312
0
Status RuntimeState::cancel_reason() const {
313
0
    if (!_exec_status.ok()) {
314
0
        return _exec_status.status();
315
0
    }
316
317
0
    if (_query_ctx) {
318
0
        return _query_ctx->exec_status();
319
0
    }
320
321
0
    return Status::Cancelled("Query cancelled");
322
0
}
323
324
const int64_t MAX_ERROR_NUM = 50;
325
326
0
Status RuntimeState::create_error_log_file() {
327
0
    if (config::save_load_error_log_to_s3 && config::is_cloud_mode()) {
328
0
        _s3_error_fs = std::dynamic_pointer_cast<io::S3FileSystem>(
329
0
                ExecEnv::GetInstance()->storage_engine().to_cloud().latest_fs());
330
0
        if (_s3_error_fs) {
331
0
            std::stringstream ss;
332
            // https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_err_packet.html
333
            // shorten the path as much as possible to prevent the length of the presigned URL from
334
            // exceeding the MySQL error packet size limit
335
0
            ss << "error_log/" << std::hex << _query_id.hi;
336
0
            _s3_error_log_file_path = ss.str();
337
0
        }
338
0
    }
339
340
0
    static_cast<void>(_exec_env->load_path_mgr()->get_load_error_file_name(
341
0
            _db_name, _import_label, _fragment_instance_id, &_error_log_file_path));
342
0
    std::string error_log_absolute_path =
343
0
            _exec_env->load_path_mgr()->get_load_error_absolute_path(_error_log_file_path);
344
0
    _error_log_file = std::make_unique<std::ofstream>(error_log_absolute_path, std::ifstream::out);
345
0
    if (!_error_log_file->is_open()) {
346
0
        std::stringstream error_msg;
347
0
        error_msg << "Fail to open error file: [" << _error_log_file_path << "].";
348
0
        LOG(WARNING) << error_msg.str();
349
0
        return Status::InternalError(error_msg.str());
350
0
    }
351
0
    LOG(INFO) << "create error log file: " << _error_log_file_path
352
0
              << ", query id: " << print_id(_query_id)
353
0
              << ", fragment instance id: " << print_id(_fragment_instance_id);
354
355
0
    return Status::OK();
356
0
}
357
358
Status RuntimeState::append_error_msg_to_file(std::function<std::string()> line,
359
                                              std::function<std::string()> error_msg,
360
0
                                              bool* stop_processing, bool is_summary) {
361
0
    *stop_processing = false;
362
0
    if (query_type() != TQueryType::LOAD) {
363
0
        return Status::OK();
364
0
    }
365
    // If file haven't been opened, open it here
366
0
    if (_error_log_file == nullptr) {
367
0
        Status status = create_error_log_file();
368
0
        if (!status.ok()) {
369
0
            LOG(WARNING) << "Create error file log failed. because: " << status;
370
0
            if (_error_log_file != nullptr) {
371
0
                _error_log_file->close();
372
0
            }
373
0
            return status;
374
0
        }
375
0
    }
376
377
    // if num of printed error row exceeds the limit, and this is not a summary message,
378
    // if _load_zero_tolerance, return Error to stop the load process immediately.
379
0
    if (_num_print_error_rows.fetch_add(1, std::memory_order_relaxed) > MAX_ERROR_NUM &&
380
0
        !is_summary) {
381
0
        if (_load_zero_tolerance) {
382
0
            *stop_processing = true;
383
0
        }
384
0
        return Status::OK();
385
0
    }
386
387
0
    fmt::memory_buffer out;
388
0
    if (is_summary) {
389
0
        fmt::format_to(out, "Summary: {}", error_msg());
390
0
    } else {
391
0
        if (_error_row_number < MAX_ERROR_NUM) {
392
            // Note: export reason first in case src line too long and be truncated.
393
0
            fmt::format_to(out, "Reason: {}. src line [{}]; ", error_msg(), line());
394
0
        } else if (_error_row_number == MAX_ERROR_NUM) {
395
0
            fmt::format_to(out, "TOO MUCH ERROR! already reach {}. show no more next error.",
396
0
                           MAX_ERROR_NUM);
397
0
        }
398
0
    }
399
400
0
    size_t error_row_size = out.size();
401
0
    if (error_row_size > 0) {
402
0
        if (error_row_size > config::load_error_log_limit_bytes) {
403
0
            fmt::memory_buffer limit_byte_out;
404
0
            limit_byte_out.append(out.data(), out.data() + config::load_error_log_limit_bytes);
405
0
            (*_error_log_file) << fmt::to_string(limit_byte_out) + "error log is too long"
406
0
                               << std::endl;
407
0
        } else {
408
0
            (*_error_log_file) << fmt::to_string(out) << std::endl;
409
0
        }
410
0
    }
411
0
    return Status::OK();
412
0
}
413
414
0
std::string RuntimeState::get_error_log_file_path() {
415
0
    std::lock_guard<std::mutex> l(_s3_error_log_file_lock);
416
0
    if (_s3_error_fs && _error_log_file && _error_log_file->is_open()) {
417
        // close error log file
418
0
        _error_log_file->close();
419
0
        std::string error_log_absolute_path =
420
0
                _exec_env->load_path_mgr()->get_load_error_absolute_path(_error_log_file_path);
421
        // upload error log file to s3
422
0
        Status st = _s3_error_fs->upload(error_log_absolute_path, _s3_error_log_file_path);
423
0
        if (st.ok()) {
424
            // remove local error log file
425
0
            std::filesystem::remove(error_log_absolute_path);
426
0
        } else {
427
            // upload failed and return local error log file path
428
0
            LOG(WARNING) << "Fail to upload error file to s3, error_log_file_path="
429
0
                         << _error_log_file_path << ", error=" << st;
430
0
            return _error_log_file_path;
431
0
        }
432
        // expiration must be less than a week (in seconds) for presigned url
433
0
        static const unsigned EXPIRATION_SECONDS = 7 * 24 * 60 * 60 - 1;
434
        // We should return a public endpoint to user.
435
0
        _error_log_file_path = _s3_error_fs->generate_presigned_url(_s3_error_log_file_path,
436
0
                                                                    EXPIRATION_SECONDS, true);
437
0
    }
438
0
    return _error_log_file_path;
439
0
}
440
441
78
void RuntimeState::resize_op_id_to_local_state(int operator_size) {
442
78
    _op_id_to_local_state.resize(-operator_size);
443
78
}
444
445
void RuntimeState::emplace_local_state(
446
71
        int id, std::unique_ptr<doris::pipeline::PipelineXLocalStateBase> state) {
447
71
    id = -id;
448
71
    DCHECK_LT(id, _op_id_to_local_state.size())
449
0
            << state->parent()->get_name() << " node id = " << state->parent()->node_id();
450
71
    DCHECK(!_op_id_to_local_state[id]);
451
71
    _op_id_to_local_state[id] = std::move(state);
452
71
}
453
454
246
doris::pipeline::PipelineXLocalStateBase* RuntimeState::get_local_state(int id) {
455
246
    id = -id;
456
246
    return _op_id_to_local_state[id].get();
457
246
}
458
459
31
Result<RuntimeState::LocalState*> RuntimeState::get_local_state_result(int id) {
460
31
    id = -id;
461
31
    if (id >= _op_id_to_local_state.size()) {
462
0
        return ResultError(Status::InternalError("get_local_state out of range size:{} , id:{}",
463
0
                                                 _op_id_to_local_state.size(), id));
464
0
    }
465
31
    if (!_op_id_to_local_state[id]) {
466
0
        return ResultError(Status::InternalError("get_local_state id:{} is null", id));
467
0
    }
468
31
    return _op_id_to_local_state[id].get();
469
31
};
470
471
void RuntimeState::emplace_sink_local_state(
472
38
        int id, std::unique_ptr<doris::pipeline::PipelineXSinkLocalStateBase> state) {
473
38
    DCHECK(!_sink_local_state) << " id=" << id << " state: " << state->debug_string(0);
474
38
    _sink_local_state = std::move(state);
475
38
}
476
477
90
doris::pipeline::PipelineXSinkLocalStateBase* RuntimeState::get_sink_local_state() {
478
90
    return _sink_local_state.get();
479
90
}
480
481
17
Result<RuntimeState::SinkLocalState*> RuntimeState::get_sink_local_state_result() {
482
17
    if (!_sink_local_state) {
483
0
        return ResultError(Status::InternalError("_op_id_to_sink_local_state not exist"));
484
0
    }
485
17
    return _sink_local_state.get();
486
17
}
487
488
0
bool RuntimeState::enable_page_cache() const {
489
0
    return !config::disable_storage_page_cache &&
490
0
           (_query_options.__isset.enable_page_cache && _query_options.enable_page_cache);
491
0
}
492
493
2
RuntimeFilterMgr* RuntimeState::global_runtime_filter_mgr() {
494
2
    return _query_ctx->runtime_filter_mgr();
495
2
}
496
497
Status RuntimeState::register_producer_runtime_filter(
498
2
        const TRuntimeFilterDesc& desc, std::shared_ptr<IRuntimeFilter>* producer_filter) {
499
    // Producers are created by local runtime filter mgr and shared by global runtime filter manager.
500
    // When RF is published, consumers in both global and local RF mgr will be found.
501
2
    RETURN_IF_ERROR(local_runtime_filter_mgr()->register_producer_filter(desc, query_options(),
502
2
                                                                         producer_filter));
503
2
    RETURN_IF_ERROR(global_runtime_filter_mgr()->register_local_merge_producer_filter(
504
2
            desc, query_options(), *producer_filter));
505
2
    return Status::OK();
506
2
}
507
508
Status RuntimeState::register_consumer_runtime_filter(
509
        const doris::TRuntimeFilterDesc& desc, bool need_local_merge, int node_id,
510
0
        std::shared_ptr<IRuntimeFilter>* consumer_filter) {
511
0
    if (desc.has_remote_targets || need_local_merge) {
512
0
        return global_runtime_filter_mgr()->register_consumer_filter(desc, query_options(), node_id,
513
0
                                                                     consumer_filter, true);
514
0
    } else {
515
0
        return local_runtime_filter_mgr()->register_consumer_filter(desc, query_options(), node_id,
516
0
                                                                    consumer_filter, false);
517
0
    }
518
0
}
519
520
0
bool RuntimeState::is_nereids() const {
521
0
    return _query_ctx->is_nereids();
522
0
}
523
524
0
std::vector<std::shared_ptr<RuntimeProfile>> RuntimeState::pipeline_id_to_profile() {
525
0
    std::shared_lock lc(_pipeline_profile_lock);
526
0
    return _pipeline_id_to_profile;
527
0
}
528
529
std::vector<std::shared_ptr<RuntimeProfile>> RuntimeState::build_pipeline_profile(
530
0
        std::size_t pipeline_size) {
531
0
    std::unique_lock lc(_pipeline_profile_lock);
532
0
    if (!_pipeline_id_to_profile.empty()) {
533
0
        throw Exception(ErrorCode::INTERNAL_ERROR,
534
0
                        "build_pipeline_profile can only be called once.");
535
0
    }
536
0
    _pipeline_id_to_profile.resize(pipeline_size);
537
0
    {
538
0
        size_t pip_idx = 0;
539
0
        for (auto& pipeline_profile : _pipeline_id_to_profile) {
540
0
            pipeline_profile =
541
0
                    std::make_shared<RuntimeProfile>("Pipeline : " + std::to_string(pip_idx));
542
0
            pip_idx++;
543
0
        }
544
0
    }
545
0
    return _pipeline_id_to_profile;
546
0
}
547
548
22
bool RuntimeState::low_memory_mode() const {
549
22
#ifdef BE_TEST
550
22
    if (!_query_ctx) {
551
0
        return false;
552
0
    }
553
22
#endif
554
22
    return _query_ctx->low_memory_mode();
555
22
}
556
557
#include "common/compile_check_end.h"
558
} // end namespace doris