Coverage Report

Created: 2026-10-14 14:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/runtime/runtime_state.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
// This file is copied from
18
// https://github.com/apache/impala/blob/branch-2.9.0/be/src/runtime/runtime-state.h
19
// and modified by Doris
20
21
#pragma once
22
23
#include <gen_cpp/PaloInternalService_types.h>
24
#include <gen_cpp/Types_types.h>
25
#include <gen_cpp/segment_v2.pb.h>
26
#include <stdint.h>
27
28
#include <atomic>
29
#include <cstdint>
30
#include <fstream>
31
#include <functional>
32
#include <memory>
33
#include <mutex>
34
#include <shared_mutex>
35
#include <string>
36
#include <vector>
37
38
#include "agent/be_exec_version_manager.h"
39
#include "cctz/time_zone.h"
40
#include "common/be_mock_util.h"
41
#include "common/compiler_util.h" // IWYU pragma: keep
42
#include "common/config.h"
43
#include "common/factory_creator.h"
44
#include "common/status.h"
45
#include "exec/scan/vector_search_user_params.h"
46
#include "runtime/runtime_profile.h"
47
#include "runtime/task_execution_context.h"
48
#include "runtime/workload_group/workload_group_fwd.h"
49
#include "util/debug_util.h"
50
#include "util/timezone_utils.h"
51
52
namespace doris {
53
namespace io {
54
class S3FileSystem;
55
} // namespace io
56
class RuntimeFilter;
57
58
2.73M
inline int32_t get_execution_rpc_timeout_ms(int32_t execution_timeout_sec) {
59
2.73M
    return std::min(config::execution_max_rpc_timeout_sec, execution_timeout_sec) * 1000;
60
2.73M
}
61
62
class PipelineXLocalStateBase;
63
class PipelineXSinkLocalStateBase;
64
class PipelineFragmentContext;
65
class PipelineTask;
66
class Dependency;
67
68
class DescriptorTbl;
69
class ObjectPool;
70
class ExecEnv;
71
class IdFileMap;
72
class RuntimeFilterMgr;
73
class MemTrackerLimiter;
74
class QueryContext;
75
class RuntimeFilterConsumer;
76
class RuntimeFilterProducer;
77
class TaskExecutionContext;
78
79
// Keep RuntimeState self-contained without importing the full frontend Thrift service header.
80
class TReportExecStatusParams;
81
class RuntimeState;
82
83
// Owns a share of the external-file report budget until the prepared commit messages are
84
// published. Destruction releases an unpublished reservation automatically.
85
class ExternalFileReportReservation {
86
public:
87
5
    ExternalFileReportReservation() = default;
88
    ~ExternalFileReportReservation();
89
90
    ExternalFileReportReservation(const ExternalFileReportReservation&) = delete;
91
    ExternalFileReportReservation& operator=(const ExternalFileReportReservation&) = delete;
92
93
private:
94
    friend class RuntimeState;
95
96
    RuntimeState* _state = nullptr;
97
    size_t _reserved_bytes = 0;
98
};
99
100
class ExternalFileReportState {
101
    friend class RuntimeState;
102
103
private:
104
    std::mutex mutex;
105
    size_t serialized_commit_bytes = 0;
106
    bool ownership_may_have_transferred = false;
107
    std::vector<std::function<void()>> rejected_report_cleanups;
108
};
109
110
enum class ExternalFileReportOutcome { ACKNOWLEDGED, REJECTED, AMBIGUOUS };
111
112
// A collection of items that are part of the global state of a
113
// query and shared across all execution nodes of that query.
114
class RuntimeState {
115
    ENABLE_FACTORY_CREATOR(RuntimeState);
116
117
public:
118
    RuntimeState(const TPlanFragmentExecParams& fragment_exec_params,
119
                 const TQueryOptions& query_options, const TQueryGlobals& query_globals,
120
                 ExecEnv* exec_env, QueryContext* ctx,
121
                 const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker = nullptr);
122
123
    RuntimeState(const TUniqueId& instance_id, const TUniqueId& query_id, int32_t fragment_id,
124
                 const TQueryOptions& query_options, const TQueryGlobals& query_globals,
125
                 ExecEnv* exec_env, QueryContext* ctx);
126
127
    // Used by pipeline. This runtime state is only used for setup.
128
    RuntimeState(const TUniqueId& query_id, int32_t fragment_id, const TQueryOptions& query_options,
129
                 const TQueryGlobals& query_globals, ExecEnv* exec_env, QueryContext* ctx);
130
131
    // Only used in the materialization phase of delayed materialization,
132
    // when there may be no corresponding QueryContext.
133
    RuntimeState(const TUniqueId& query_id, int32_t fragment_id, const TQueryOptions& query_options,
134
                 const TQueryGlobals& query_globals, ExecEnv* exec_env,
135
                 const std::shared_ptr<MemTrackerLimiter>& query_mem_tracker);
136
137
    // RuntimeState for executing expr in fe-support.
138
    RuntimeState(const TQueryOptions& query_options, const TQueryGlobals& query_globals);
139
140
    // for job task only
141
    RuntimeState();
142
143
    // Empty d'tor to avoid issues with unique_ptr.
144
    MOCK_DEFINE(virtual) ~RuntimeState();
145
146
    // Set per-query state.
147
    Status init(const TUniqueId& fragment_instance_id, const TQueryOptions& query_options,
148
                const TQueryGlobals& query_globals, ExecEnv* exec_env);
149
150
    // for ut and non-query.
151
    void set_exec_env(ExecEnv* exec_env) { _exec_env = exec_env; }
152
153
    // for ut and non-query.
154
    void init_mem_trackers(const std::string& name = "ut", const TUniqueId& id = TUniqueId());
155
156
37.7M
    const TQueryOptions& query_options() const { return _query_options; }
157
230k
    int64_t scan_queue_mem_limit() const {
158
230k
        return _query_options.__isset.scan_queue_mem_limit ? _query_options.scan_queue_mem_limit
159
230k
                                                           : _query_options.mem_limit / 20;
160
230k
    }
161
162
788k
    bool enable_adjust_conjunct_order_by_cost() const {
163
788k
        return _query_options.__isset.enable_adjust_conjunct_order_by_cost &&
164
788k
               _query_options.enable_adjust_conjunct_order_by_cost;
165
788k
    }
166
167
230k
    int32_t max_column_reader_num() const {
168
230k
        return _query_options.__isset.max_column_reader_num ? _query_options.max_column_reader_num
169
230k
                                                            : 20000;
170
230k
    }
171
172
6.60M
    ObjectPool* obj_pool() const { return _obj_pool.get(); }
173
174
5.09M
    const DescriptorTbl& desc_tbl() const { return *_desc_tbl; }
175
2.46M
    void set_desc_tbl(const DescriptorTbl* desc_tbl) { _desc_tbl = desc_tbl; }
176
177
    // Row-count limit for output blocks. Clamp to [1, 65535].
178
    // Adaptive byte budgeting still uses this as the hard row ceiling.
179
17.8M
    MOCK_FUNCTION int batch_size() const {
180
17.8M
        static constexpr int kMax = 65535;
181
17.8M
        auto v = _query_options.batch_size;
182
17.8M
        return std::min(std::max(1, v), kMax);
183
17.8M
    }
184
185
    // Target byte budget per output block (default 8MB when adaptive is enabled).
186
    // The public FE/session contract is [1MB, 512MB]; this accessor still clamps any direct
187
    // thrift or mixed-version out-of-range value into that range. Returns `kMax` when adaptive
188
    // is disabled by BE config so the value is always a legal byte budget; callers that need
189
    // to know whether adaptive batch size is active should test
190
    // `config::enable_adaptive_batch_size` explicitly.
191
4.05M
    MOCK_FUNCTION size_t preferred_block_size_bytes() const {
192
4.05M
        static constexpr int64_t kDefault = 8388608L; // 8MB
193
4.05M
        static constexpr int64_t kMax = 536870912L;   // 512MB
194
4.05M
        static constexpr int64_t kMin = 1048576L;     // 1MB
195
4.05M
        if (!config::enable_adaptive_batch_size) [[unlikely]] {
196
8.99k
            return kMax;
197
8.99k
        }
198
4.05M
        if (_query_options.__isset.preferred_block_size_bytes) [[likely]] {
199
4.05M
            return std::max<int64_t>(
200
4.05M
                    kMin, std::min<int64_t>(_query_options.preferred_block_size_bytes, kMax));
201
4.05M
        }
202
18.4E
        return kDefault;
203
4.04M
    }
204
205
926k
    int query_parallel_instance_num() const { return _query_options.parallel_instance; }
206
0
    int max_errors() const { return _query_options.max_errors; }
207
3.01M
    int execution_timeout() const {
208
3.02M
        return _query_options.__isset.execution_timeout ? _query_options.execution_timeout
209
18.4E
                                                        : _query_options.query_timeout;
210
3.01M
    }
211
434k
    int max_scanners_concurrency() const {
212
434k
        return _query_options.__isset.max_scanners_concurrency
213
436k
                       ? _query_options.max_scanners_concurrency
214
18.4E
                       : 0;
215
434k
    }
216
11.6k
    int max_file_scanners_concurrency() const {
217
11.6k
        return _query_options.__isset.max_file_scanners_concurrency
218
11.6k
                       ? _query_options.max_file_scanners_concurrency
219
18.4E
                       : max_scanners_concurrency();
220
11.6k
    }
221
222
436k
    int min_scanners_concurrency() const {
223
436k
        return _query_options.__isset.min_scanners_concurrency
224
437k
                       ? _query_options.min_scanners_concurrency
225
18.4E
                       : 1;
226
436k
    }
227
228
3.87k
    int min_file_scanners_concurrency() const {
229
3.87k
        return _query_options.__isset.min_file_scanners_concurrency
230
3.87k
                       ? _query_options.min_file_scanners_concurrency
231
18.4E
                       : 1;
232
3.87k
    }
233
234
    // Support extended regex
235
    // like look-around zero-width assertions(`?=`, `?!`, `?<=`, `?<!`)
236
8.96k
    bool enable_extended_regex() const {
237
8.96k
        return _query_options.__isset.enable_extended_regex && _query_options.enable_extended_regex;
238
8.96k
    }
239
240
95.7k
    TQueryType::type query_type() const { return _query_options.query_type; }
241
48.7k
    int64_t timestamp_ms() const { return _timestamp_ms; }
242
48.9k
    int32_t nano_seconds() const { return _nano_seconds; }
243
    // if possible, use timezone_obj() rather than timezone()
244
259k
    const std::string& timezone() const { return _timezone; }
245
332k
    const cctz::time_zone& timezone_obj() const { return _timezone_obj; }
246
428
    void set_timezone(const std::string& timezone) {
247
428
        _timezone = timezone;
248
428
        TimezoneUtils::find_cctz_time_zone(_timezone, _timezone_obj);
249
428
    }
250
495
    const std::string& lc_time_names() const { return _lc_time_names; }
251
13.2M
    const TUniqueId& query_id() const { return _query_id; }
252
2.17M
    const TUniqueId& fragment_instance_id() const { return _fragment_instance_id; }
253
    // should only be called in pipeline engine
254
786
    int32_t fragment_id() const { return _fragment_id; }
255
3.63M
    ExecEnv* exec_env() { return _exec_env; }
256
    std::shared_ptr<MemTrackerLimiter> query_mem_tracker() const;
257
258
    // Returns runtime state profile
259
1.57k
    RuntimeProfile* runtime_profile() { return &_profile; }
260
84.4k
    RuntimeProfile* load_channel_profile() { return &_load_channel_profile; }
261
262
295k
    bool enable_function_pushdown() const {
263
295k
        return _query_options.__isset.enable_function_pushdown &&
264
296k
               _query_options.enable_function_pushdown;
265
295k
    }
266
267
718k
    bool check_overflow_for_decimal() const {
268
718k
        return _query_options.__isset.check_overflow_for_decimal &&
269
718k
               _query_options.check_overflow_for_decimal;
270
718k
    }
271
272
721k
    bool enable_strict_mode() const {
273
721k
        return _query_options.__isset.enable_strict_cast && _query_options.enable_strict_cast;
274
721k
    }
275
276
107
    bool enable_insert_strict() const {
277
107
        return _query_options.__isset.enable_insert_strict && _query_options.enable_insert_strict;
278
107
    }
279
280
929k
    bool enable_segment_limit_pushdown() const {
281
929k
        return !_query_options.__isset.enable_segment_limit_pushdown ||
282
931k
               _query_options.enable_segment_limit_pushdown;
283
929k
    }
284
285
383k
    bool mysql_row_binary_format() const {
286
383k
        return _query_options.__isset.mysql_row_binary_format &&
287
383k
               _query_options.mysql_row_binary_format;
288
383k
    }
289
290
22
    bool enable_short_circuit_query_access_column_store() const {
291
22
        return _query_options.__isset.enable_short_circuit_query_access_column_store &&
292
22
               _query_options.enable_short_circuit_query_access_column_store;
293
22
    }
294
295
    // Appends error to the _error_log if there is space
296
    bool log_error(const std::string& error);
297
298
    // Returns true if the error log has not reached _max_errors.
299
0
    bool log_has_space() {
300
0
        std::lock_guard<std::mutex> l(_error_log_lock);
301
0
        return _error_log.size() < _query_options.max_errors;
302
0
    }
303
304
    // Append all _error_log[_unreported_error_idx+] to new_errors and set
305
    // _unreported_error_idx to _errors_log.size()
306
    void get_unreported_errors(std::vector<std::string>* new_errors);
307
308
    [[nodiscard]] MOCK_FUNCTION bool is_cancelled() const;
309
    MOCK_FUNCTION Status cancel_reason() const;
310
30
    void cancel(const Status& reason) {
311
30
        if (_exec_status.update(reason)) {
312
            // Create a error status, so that we could print error stack, and
313
            // we could know which path call cancel.
314
30
            LOG(WARNING) << "Task is cancelled, instance: "
315
30
                         << PrintInstanceStandardInfo(_query_id, _fragment_instance_id)
316
30
                         << ", st = " << reason;
317
30
        } else {
318
0
            LOG(WARNING) << "Task is already cancelled, instance: "
319
0
                         << PrintInstanceStandardInfo(_query_id, _fragment_instance_id)
320
0
                         << ", original cancel msg: " << _exec_status.status()
321
0
                         << ", new cancel msg: " << reason;
322
0
        }
323
30
    }
324
325
2.16M
    void set_backend_id(int64_t backend_id) { _backend_id = backend_id; }
326
37
    int64_t backend_id() const { return _backend_id; }
327
328
1.80M
    void set_be_number(int be_number) { _be_number = be_number; }
329
3.97M
    int be_number(void) const { return _be_number; }
330
331
6.02k
    std::vector<std::string>& output_files() { return _output_files; }
332
333
1.72k
    void set_import_label(const std::string& import_label) { _import_label = import_label; }
334
335
203k
    const std::vector<std::string>& export_output_files() const { return _export_output_files; }
336
337
0
    void add_export_output_file(const std::string& file) { _export_output_files.push_back(file); }
338
339
493
    void set_db_name(const std::string& db_name) { _db_name = db_name; }
340
341
0
    const std::string& db_name() { return _db_name; }
342
343
1.24k
    void set_wal_id(int64_t wal_id) { _wal_id = wal_id; }
344
345
160k
    int64_t wal_id() const { return _wal_id; }
346
347
427
    void set_content_length(size_t content_length) { _content_length = content_length; }
348
349
4
    size_t content_length() const { return _content_length; }
350
351
573
    const std::string& import_label() { return _import_label; }
352
353
0
    const std::string& load_dir() const { return _load_dir; }
354
355
0
    void set_load_job_id(int64_t job_id) { _load_job_id = job_id; }
356
357
48.3k
    int64_t load_job_id() const { return _load_job_id; }
358
359
    std::string get_error_log_file_path();
360
361
    std::string get_first_error_msg() const;
362
363
    // append error msg and error line to file when loading data.
364
    // is_summary is true, means we are going to write the summary line
365
    // If we need to stop the processing, set stop_processing to true
366
    Status append_error_msg_to_file(std::function<std::string()> line,
367
                                    std::function<std::string()> error_msg);
368
369
74.1k
    int64_t num_bytes_load_total() { return _num_bytes_load_total.load(); }
370
371
203k
    int64_t num_finished_range() { return _num_finished_scan_range.load(); }
372
373
316k
    int64_t num_rows_load_total() { return _num_rows_load_total.load(); }
374
375
293k
    int64_t num_rows_load_filtered() { return _num_rows_load_filtered.load(); }
376
377
123k
    int64_t num_rows_load_unselected() { return _num_rows_load_unselected.load(); }
378
379
98.5k
    int64_t num_rows_filtered_in_strict_mode_partial_update() {
380
98.5k
        return _num_rows_filtered_in_strict_mode_partial_update;
381
98.5k
    }
382
383
36.4k
    int64_t num_rows_load_success() {
384
36.4k
        return num_rows_load_total() - num_rows_load_filtered() - num_rows_load_unselected();
385
36.4k
    }
386
387
42.4k
    void update_num_rows_load_total(int64_t num_rows) { _num_rows_load_total.fetch_add(num_rows); }
388
389
49.8k
    void set_num_rows_load_total(int64_t num_rows) { _num_rows_load_total.store(num_rows); }
390
391
42.4k
    void update_num_bytes_load_total(int64_t bytes_load) {
392
42.4k
        _num_bytes_load_total.fetch_add(bytes_load);
393
42.4k
    }
394
395
3.22k
    void update_num_finished_scan_range(int64_t finished_range) {
396
3.22k
        _num_finished_scan_range.fetch_add(finished_range);
397
3.22k
    }
398
399
52.5k
    void update_num_rows_load_filtered(int64_t num_rows) {
400
52.5k
        _num_rows_load_filtered.fetch_add(num_rows);
401
52.5k
    }
402
403
51.9k
    void update_num_rows_load_unselected(int64_t num_rows) {
404
51.9k
        _num_rows_load_unselected.fetch_add(num_rows);
405
51.9k
    }
406
407
70
    void set_num_rows_filtered_in_strict_mode_partial_update(int64_t num_rows) {
408
70
        _num_rows_filtered_in_strict_mode_partial_update = num_rows;
409
70
    }
410
411
1.80M
    void set_per_fragment_instance_idx(int idx) { _per_fragment_instance_idx = idx; }
412
413
265k
    int per_fragment_instance_idx() const { return _per_fragment_instance_idx; }
414
415
2.17M
    void set_num_per_fragment_instances(int num_instances) {
416
2.17M
        _num_per_fragment_instances = num_instances;
417
2.17M
    }
418
419
47.8k
    int num_per_fragment_instances() const { return _num_per_fragment_instances; }
420
421
2.16M
    void set_load_stream_per_node(int load_stream_per_node) {
422
2.16M
        _load_stream_per_node = load_stream_per_node;
423
2.16M
    }
424
425
18
    int load_stream_per_node() const { return _load_stream_per_node; }
426
427
2.16M
    void set_total_load_streams(int total_load_streams) {
428
2.16M
        _total_load_streams = total_load_streams;
429
2.16M
    }
430
431
18
    int total_load_streams() const { return _total_load_streams; }
432
433
2.16M
    void set_num_local_sink(int num_local_sink) { _num_local_sink = num_local_sink; }
434
435
18
    int num_local_sink() const { return _num_local_sink; }
436
437
0
    bool disable_stream_preaggregations() const {
438
0
        return _query_options.disable_stream_preaggregations;
439
0
    }
440
441
0
    int32_t runtime_filter_wait_time_ms() const {
442
0
        return _query_options.runtime_filter_wait_time_ms;
443
0
    }
444
445
1.34k
    int32_t runtime_filter_max_in_num() const { return _query_options.runtime_filter_max_in_num; }
446
447
19.3M
    int be_exec_version() const {
448
19.3M
        DCHECK(_query_options.__isset.be_exec_version &&
449
19.3M
               BeExecVersionManager::check_be_exec_version(_query_options.be_exec_version));
450
19.3M
        return _query_options.be_exec_version;
451
19.3M
    }
452
368k
    bool plan_local_shuffle() const {
453
        // If local shuffle is enabled and not planned by local shuffle planner, we should plan local shuffle in BE.
454
368k
        return _query_options.__isset.enable_local_shuffle && _query_options.enable_local_shuffle &&
455
368k
               (!_query_options.__isset.enable_local_shuffle_planner ||
456
366k
                !_query_options.enable_local_shuffle_planner);
457
368k
    }
458
459
2.73M
    MOCK_FUNCTION bool enable_local_exchange() const {
460
2.74M
        return _query_options.__isset.enable_local_exchange && _query_options.enable_local_exchange;
461
2.73M
    }
462
463
3.76k
    bool trim_tailing_spaces_for_external_table_query() const {
464
3.76k
        return _query_options.trim_tailing_spaces_for_external_table_query;
465
3.76k
    }
466
467
380k
    bool return_object_data_as_binary() const {
468
380k
        return _query_options.return_object_data_as_binary;
469
380k
    }
470
471
6.27M
    bool enable_fuzzy_blockable_task() const {
472
6.27M
        return _query_options.__isset.enable_fuzzy_blockable_task &&
473
6.28M
               _query_options.enable_fuzzy_blockable_task;
474
6.27M
    }
475
476
373k
    segment_v2::CompressionTypePB fragement_transmission_compression_type() const {
477
373k
        if (_query_options.__isset.fragment_transmission_compression_codec) {
478
370k
            if (_query_options.fragment_transmission_compression_codec == "lz4") {
479
127k
                return segment_v2::CompressionTypePB::LZ4;
480
242k
            } else if (_query_options.fragment_transmission_compression_codec == "snappy") {
481
113k
                return segment_v2::CompressionTypePB::SNAPPY;
482
129k
            } else {
483
129k
                return segment_v2::CompressionTypePB::NO_COMPRESSION;
484
129k
            }
485
370k
        }
486
2.74k
        return segment_v2::CompressionTypePB::NO_COMPRESSION;
487
373k
    }
488
489
1.86M
    bool skip_storage_engine_merge() const {
490
1.86M
        return _query_options.__isset.skip_storage_engine_merge &&
491
1.87M
               _query_options.skip_storage_engine_merge;
492
1.86M
    }
493
494
1.08M
    bool skip_delete_predicate() const {
495
1.08M
        return _query_options.__isset.skip_delete_predicate && _query_options.skip_delete_predicate;
496
1.08M
    }
497
498
934k
    bool skip_delete_bitmap() const {
499
936k
        return _query_options.__isset.skip_delete_bitmap && _query_options.skip_delete_bitmap;
500
934k
    }
501
502
1.08M
    bool skip_missing_version() const {
503
1.08M
        return _query_options.__isset.skip_missing_version && _query_options.skip_missing_version;
504
1.08M
    }
505
506
9.07k
    int64_t data_queue_max_blocks() const {
507
9.08k
        return _query_options.__isset.data_queue_max_blocks ? _query_options.data_queue_max_blocks
508
18.4E
                                                            : 1;
509
9.07k
    }
510
511
    bool enable_page_cache() const;
512
513
1.05M
    bool enable_prefer_cached_rowset() const {
514
1.05M
        return _query_options.__isset.enable_prefer_cached_rowset &&
515
1.06M
               _query_options.enable_prefer_cached_rowset;
516
1.05M
    }
517
518
1.05M
    int64_t query_freshness_tolerance_ms() const {
519
1.05M
        return _query_options.query_freshness_tolerance_ms;
520
1.05M
    }
521
522
0
    bool enable_query_freshness_tolerance() const {
523
0
        return _query_options.__isset.query_freshness_tolerance_ms &&
524
0
               _query_options.query_freshness_tolerance_ms > 0;
525
0
    }
526
527
206k
    std::vector<TTabletCommitInfo> tablet_commit_infos() const {
528
206k
        std::lock_guard<std::mutex> lock(_tablet_infos_mutex);
529
206k
        return _tablet_commit_infos;
530
206k
    }
531
532
50.5k
    void add_tablet_commit_infos(std::vector<TTabletCommitInfo>& commit_infos) {
533
50.5k
        std::lock_guard<std::mutex> lock(_tablet_infos_mutex);
534
50.5k
        _tablet_commit_infos.insert(_tablet_commit_infos.end(),
535
50.5k
                                    std::make_move_iterator(commit_infos.begin()),
536
50.5k
                                    std::make_move_iterator(commit_infos.end()));
537
50.5k
    }
538
539
203k
    std::vector<TErrorTabletInfo> error_tablet_infos() const {
540
203k
        std::lock_guard<std::mutex> lock(_tablet_infos_mutex);
541
203k
        return _error_tablet_infos;
542
203k
    }
543
544
50.4k
    void add_error_tablet_infos(std::vector<TErrorTabletInfo>& tablet_infos) {
545
50.4k
        std::lock_guard<std::mutex> lock(_tablet_infos_mutex);
546
50.4k
        _error_tablet_infos.insert(_error_tablet_infos.end(),
547
50.4k
                                   std::make_move_iterator(tablet_infos.begin()),
548
50.4k
                                   std::make_move_iterator(tablet_infos.end()));
549
50.4k
    }
550
551
178k
    std::vector<THivePartitionUpdate> hive_partition_updates() const {
552
178k
        std::lock_guard<std::mutex> lock(_hive_partition_updates_mutex);
553
178k
        return _hive_partition_updates;
554
178k
    }
555
556
8
    void add_hive_partition_updates(const THivePartitionUpdate& hive_partition_update) {
557
8
        std::lock_guard<std::mutex> lock(_hive_partition_updates_mutex);
558
8
        _hive_partition_updates.emplace_back(hive_partition_update);
559
8
    }
560
561
179k
    void append_iceberg_commit_datas(std::vector<TIcebergCommitData>* output) const {
562
179k
        std::lock_guard<std::mutex> lock(_iceberg_commit_datas_mutex);
563
179k
        output->insert(output->end(), _iceberg_commit_datas.begin(), _iceberg_commit_datas.end());
564
179k
    }
565
566
    Status add_iceberg_commit_datas(TIcebergCommitData iceberg_commit_data);
567
568
    // Reserve report space before closing the Paimon writer, then either publish the prepared
569
    // messages after a clean close or let the reservation release itself while aborting the writer.
570
    Status reserve_paimon_commit_messages(const std::vector<TPaimonCommitMessage>& commit_messages,
571
                                          ExternalFileReportReservation* reservation);
572
573
    void publish_reserved_paimon_commit_messages(std::vector<TPaimonCommitMessage> commit_messages,
574
                                                 ExternalFileReportReservation* reservation);
575
576
179k
    void append_paimon_commit_messages(std::vector<TPaimonCommitMessage>* output) const {
577
179k
        std::lock_guard<std::mutex> lock(_paimon_commit_messages_mutex);
578
179k
        output->insert(output->end(), _paimon_commit_messages.begin(),
579
179k
                       _paimon_commit_messages.end());
580
179k
    }
581
582
    size_t coordinator_thrift_message_limit() const;
583
584
    void append_external_file_commit_data(TReportExecStatusParams* params, bool final_report) const;
585
586
    void add_rejected_external_file_report_cleanup(std::function<void()> cleanup);
587
588
    void finalize_external_file_report_cleanup(ExternalFileReportOutcome outcome);
589
590
1.80M
    void set_external_file_report_state(std::shared_ptr<ExternalFileReportState> report_state) {
591
1.80M
        _external_file_report_state = std::move(report_state);
592
1.80M
    }
593
594
1.80M
    const std::shared_ptr<ExternalFileReportState>& external_file_report_state() const {
595
1.80M
        return _external_file_report_state;
596
1.80M
    }
597
598
179k
    std::vector<TMCCommitData> mc_commit_datas() const {
599
179k
        std::lock_guard<std::mutex> lock(_mc_commit_datas_mutex);
600
179k
        return _mc_commit_datas;
601
179k
    }
602
603
1
    void add_mc_commit_datas(const TMCCommitData& mc_commit_data) {
604
1
        std::lock_guard<std::mutex> lock(_mc_commit_datas_mutex);
605
1
        _mc_commit_datas.emplace_back(mc_commit_data);
606
1
    }
607
608
    // local runtime filter mgr, the runtime filter do not have remote target or
609
    // not need local merge should regist here. the instance exec finish, the local
610
    // runtime filter mgr can release the memory of local runtime filter
611
87.2k
    RuntimeFilterMgr* local_runtime_filter_mgr() { return _runtime_filter_mgr; }
612
613
    RuntimeFilterMgr* global_runtime_filter_mgr();
614
615
1.79M
    void set_runtime_filter_mgr(RuntimeFilterMgr* runtime_filter_mgr) {
616
1.79M
        _runtime_filter_mgr = runtime_filter_mgr;
617
1.79M
    }
618
619
71.4M
    QueryContext* get_query_ctx() const { return _query_ctx; }
620
621
    [[nodiscard]] bool low_memory_mode() const;
622
623
    std::weak_ptr<QueryContext> get_query_ctx_weak();
624
    MOCK_FUNCTION WorkloadGroupPtr workload_group();
625
626
1.80M
    void set_query_mem_tracker(const std::shared_ptr<MemTrackerLimiter>& tracker) {
627
1.80M
        _query_mem_tracker = tracker;
628
1.80M
    }
629
630
4.73k
    void set_query_options(const TQueryOptions& query_options) { _query_options = query_options; }
631
632
2.83M
    bool enable_profile() const {
633
2.83M
        return _query_options.__isset.enable_profile && _query_options.enable_profile;
634
2.83M
    }
635
636
169
    int cte_max_recursion_depth() const {
637
169
        return _query_options.__isset.cte_max_recursion_depth
638
169
                       ? _query_options.cte_max_recursion_depth
639
169
                       : 0;
640
169
    }
641
642
2
    bool enable_streaming_agg_hash_join_force_passthrough() const {
643
2
        return _query_options.__isset.enable_streaming_agg_hash_join_force_passthrough &&
644
2
               _query_options.enable_streaming_agg_hash_join_force_passthrough;
645
2
    }
646
647
39.0k
    bool enable_local_exchange_before_agg() const {
648
39.0k
        return _query_options.__isset.enable_local_exchange_before_agg &&
649
39.1k
               _query_options.enable_local_exchange_before_agg;
650
39.0k
    }
651
652
1.64k
    bool enable_local_exchange_before_streaming_agg() const {
653
1.64k
        return _query_options.__isset.enable_local_exchange_before_streaming_agg &&
654
1.64k
               _query_options.enable_local_exchange_before_streaming_agg;
655
1.64k
    }
656
657
8.74k
    bool enable_distinct_streaming_agg_force_passthrough() const {
658
8.74k
        return _query_options.__isset.enable_distinct_streaming_agg_force_passthrough &&
659
8.74k
               _query_options.enable_distinct_streaming_agg_force_passthrough;
660
8.74k
    }
661
662
9.63k
    bool enable_broadcast_join_force_passthrough() const {
663
9.63k
        return _query_options.__isset.enable_broadcast_join_force_passthrough &&
664
9.63k
               _query_options.enable_broadcast_join_force_passthrough;
665
9.63k
    }
666
667
264k
    int rpc_verbose_profile_max_instance_count() const {
668
264k
        return _query_options.__isset.rpc_verbose_profile_max_instance_count
669
264k
                       ? _query_options.rpc_verbose_profile_max_instance_count
670
18.4E
                       : 0;
671
264k
    }
672
673
15.4k
    MOCK_FUNCTION bool enable_share_hash_table_for_broadcast_join() const {
674
15.4k
        return _query_options.__isset.enable_share_hash_table_for_broadcast_join &&
675
15.4k
               _query_options.enable_share_hash_table_for_broadcast_join;
676
15.4k
    }
677
678
235k
    bool enable_parallel_scan() const {
679
236k
        return _query_options.__isset.enable_parallel_scan && _query_options.enable_parallel_scan;
680
235k
    }
681
682
120k
    bool enable_aggregate_function_null_v2() const {
683
120k
        return _query_options.__isset.enable_aggregate_function_null_v2 &&
684
120k
               _query_options.enable_aggregate_function_null_v2;
685
120k
    }
686
687
1.27M
    bool enable_prune_nested_column() const {
688
1.27M
        return _query_options.__isset.enable_prune_nested_column &&
689
1.27M
               _query_options.enable_prune_nested_column;
690
1.27M
    }
691
692
28
    bool is_read_csv_empty_line_as_null() const {
693
28
        return _query_options.__isset.read_csv_empty_line_as_null &&
694
28
               _query_options.read_csv_empty_line_as_null;
695
28
    }
696
697
111k
    int parallel_scan_max_scanners_count() const {
698
111k
        return _query_options.__isset.parallel_scan_max_scanners_count
699
111k
                       ? _query_options.parallel_scan_max_scanners_count
700
111k
                       : 0;
701
111k
    }
702
703
47.6k
    int partition_topn_max_partitions() const {
704
47.6k
        return _query_options.__isset.partition_topn_max_partitions
705
47.6k
                       ? _query_options.partition_topn_max_partitions
706
47.6k
                       : 1024;
707
47.6k
    }
708
709
0
    int partition_topn_per_partition_rows() const {
710
0
        return _query_options.__isset.partition_topn_pre_partition_rows
711
0
                       ? _query_options.partition_topn_pre_partition_rows
712
0
                       : 1000;
713
0
    }
714
715
111k
    int64_t parallel_scan_min_rows_per_scanner() const {
716
111k
        return _query_options.__isset.parallel_scan_min_rows_per_scanner
717
111k
                       ? _query_options.parallel_scan_min_rows_per_scanner
718
18.4E
                       : 0;
719
111k
    }
720
721
3.29k
    void set_be_exec_version(int32_t version) noexcept { _query_options.be_exec_version = version; }
722
723
    using LocalState = doris::PipelineXLocalStateBase;
724
    using SinkLocalState = doris::PipelineXSinkLocalStateBase;
725
    // get result can return an error message, and we will only call it during the prepare.
726
    void emplace_local_state(int id, std::unique_ptr<LocalState> state);
727
728
    LocalState* get_local_state(int id);
729
    Result<LocalState*> get_local_state_result(int id);
730
731
    void emplace_sink_local_state(int id, std::unique_ptr<SinkLocalState> state);
732
733
    SinkLocalState* get_sink_local_state();
734
735
    Result<SinkLocalState*> get_sink_local_state_result();
736
737
    void resize_op_id_to_local_state(int operator_size);
738
739
    std::vector<std::shared_ptr<RuntimeProfile>> pipeline_id_to_profile();
740
741
    std::vector<std::shared_ptr<RuntimeProfile>> build_pipeline_profile(std::size_t pipeline_size);
742
743
2.25M
    void set_task_execution_context(std::shared_ptr<TaskExecutionContext> context) {
744
2.25M
        _task_execution_context_inited = true;
745
2.25M
        _task_execution_context = context;
746
2.25M
    }
747
748
57.4k
    bool task_execution_context_inited() const { return _task_execution_context_inited; }
749
750
2.06M
    std::weak_ptr<TaskExecutionContext> get_task_execution_context() {
751
18.4E
        CHECK(_task_execution_context_inited)
752
18.4E
                << "_task_execution_context_inited == false, the ctx is not inited";
753
2.06M
        return _task_execution_context;
754
2.06M
    }
755
756
    Status register_producer_runtime_filter(
757
            const doris::TRuntimeFilterDesc& desc,
758
            std::shared_ptr<RuntimeFilterProducer>* producer_filter);
759
760
    Status register_consumer_runtime_filter(
761
            const doris::TRuntimeFilterDesc& desc, bool need_local_merge, int node_id,
762
            std::shared_ptr<RuntimeFilterConsumer>* consumer_filter);
763
764
    bool is_nereids() const;
765
766
6.35M
    bool enable_spill() const {
767
6.35M
        return (_query_options.__isset.enable_force_spill && _query_options.enable_force_spill) ||
768
6.35M
               (_query_options.__isset.enable_spill && _query_options.enable_spill);
769
6.35M
    }
770
771
11.8M
    bool enable_force_spill() const {
772
11.8M
        return _query_options.__isset.enable_force_spill && _query_options.enable_force_spill;
773
11.8M
    }
774
775
12.8k
    int64_t spill_min_revocable_mem() const {
776
12.8k
        if (_query_options.__isset.min_revocable_mem) {
777
12.8k
            return std::max(_query_options.min_revocable_mem, (int64_t)1 << 20);
778
12.8k
        }
779
18.4E
        return 32 << 20;
780
12.8k
    }
781
782
263
    int spill_aggregation_partition_count() const {
783
263
        if (_query_options.__isset.spill_aggregation_partition_count) {
784
263
            return std::min(std::max(2, _query_options.spill_aggregation_partition_count), 32);
785
263
        }
786
0
        return 8;
787
263
    }
788
789
9
    int spill_hash_join_partition_count() const {
790
9
        if (_query_options.__isset.spill_hash_join_partition_count) {
791
9
            return std::min(std::max(2, _query_options.spill_hash_join_partition_count), 32);
792
9
        }
793
0
        return 8;
794
9
    }
795
796
135
    int spill_repartition_max_depth() const {
797
135
        if (_query_options.__isset.spill_repartition_max_depth) {
798
            // Clamp to a reasonable range: [1, 128]
799
135
            return std::max(1, std::min(_query_options.spill_repartition_max_depth, 128));
800
135
        }
801
0
        return 8;
802
135
    }
803
804
87
    int64_t spill_buffer_size_bytes() const {
805
        // clamp to [1MB, 256MB]
806
87
        constexpr int64_t kMin = 1LL * 1024 * 1024;
807
87
        constexpr int64_t kMax = 256LL * 1024 * 1024;
808
87
        if (_query_options.__isset.spill_buffer_size_bytes) {
809
87
            int64_t v = _query_options.spill_buffer_size_bytes;
810
87
            if (v < kMin) return kMin;
811
87
            if (v > kMax) return kMax;
812
87
            return v;
813
87
        }
814
0
        return 8LL * 1024 * 1024;
815
87
    }
816
817
    // Per-sink memory limits: after spill is triggered, the sink proactively
818
    // spills when its revocable memory exceeds this threshold.
819
    // Clamped to [1MB, 4GB], default 64MB.
820
2
    int64_t spill_join_build_sink_mem_limit_bytes() const {
821
2
        constexpr int64_t kMin = 1LL * 1024 * 1024;
822
2
        constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024;
823
2
        constexpr int64_t kDefault = 64LL * 1024 * 1024;
824
2
        if (_query_options.__isset.spill_join_build_sink_mem_limit_bytes) {
825
2
            int64_t v = _query_options.spill_join_build_sink_mem_limit_bytes;
826
2
            return std::min(std::max(v, kMin), kMax);
827
2
        }
828
0
        return kDefault;
829
2
    }
830
831
16
    int64_t spill_aggregation_sink_mem_limit_bytes() const {
832
16
        constexpr int64_t kMin = 1LL * 1024 * 1024;
833
16
        constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024;
834
16
        constexpr int64_t kDefault = 64LL * 1024 * 1024;
835
16
        if (_query_options.__isset.spill_aggregation_sink_mem_limit_bytes) {
836
16
            int64_t v = _query_options.spill_aggregation_sink_mem_limit_bytes;
837
16
            return std::min(std::max(v, kMin), kMax);
838
16
        }
839
0
        return kDefault;
840
16
    }
841
842
8
    int64_t spill_sort_sink_mem_limit_bytes() const {
843
8
        constexpr int64_t kMin = 1LL * 1024 * 1024;
844
8
        constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024;
845
8
        constexpr int64_t kDefault = 64LL * 1024 * 1024;
846
8
        if (_query_options.__isset.spill_sort_sink_mem_limit_bytes) {
847
8
            int64_t v = _query_options.spill_sort_sink_mem_limit_bytes;
848
8
            return std::min(std::max(v, kMin), kMax);
849
8
        }
850
0
        return kDefault;
851
8
    }
852
853
11
    int64_t spill_sort_merge_mem_limit_bytes() const {
854
11
        constexpr int64_t kMin = 1LL * 1024 * 1024;
855
11
        constexpr int64_t kMax = 4LL * 1024 * 1024 * 1024;
856
11
        constexpr int64_t kDefault = 64LL * 1024 * 1024;
857
11
        if (_query_options.__isset.spill_sort_merge_mem_limit_bytes) {
858
11
            int64_t v = _query_options.spill_sort_merge_mem_limit_bytes;
859
11
            return std::min(std::max(v, kMin), kMax);
860
11
        }
861
0
        return kDefault;
862
11
    }
863
864
0
    int64_t low_memory_mode_buffer_limit() const {
865
0
        if (_query_options.__isset.low_memory_mode_buffer_limit) {
866
0
            return std::max(_query_options.low_memory_mode_buffer_limit, (int64_t)1);
867
0
        }
868
0
        return 32L * 1024 * 1024;
869
0
    }
870
871
0
    int spill_revocable_memory_high_watermark_percent() const {
872
0
        if (_query_options.__isset.revocable_memory_high_watermark_percent) {
873
0
            return _query_options.revocable_memory_high_watermark_percent;
874
0
        }
875
0
        return -1;
876
0
    }
877
878
139k
    MOCK_FUNCTION bool enable_shared_exchange_sink_buffer() const {
879
139k
        return _query_options.__isset.enable_shared_exchange_sink_buffer &&
880
139k
               _query_options.enable_shared_exchange_sink_buffer;
881
139k
    }
882
883
10.0M
    size_t minimum_operator_memory_required_bytes() const {
884
10.0M
        if (_query_options.__isset.minimum_operator_memory_required_kb) {
885
10.0M
            return _query_options.minimum_operator_memory_required_kb * 1024;
886
18.4E
        } else {
887
            // refer other database
888
18.4E
            return 4 * 1024 * 1024;
889
18.4E
        }
890
10.0M
    }
891
892
259k
    MOCK_FUNCTION bool enable_use_hybrid_sort() const {
893
259k
        return _query_options.__isset.enable_use_hybrid_sort &&
894
260k
               _query_options.enable_use_hybrid_sort;
895
259k
    }
896
897
1.87M
    void set_max_operator_id(int max_operator_id) { _max_operator_id = max_operator_id; }
898
899
178
    int max_operator_id() const { return _max_operator_id; }
900
901
1.80M
    void set_task_id(int id) { _task_id = id; }
902
903
355
    int task_id() const { return _task_id; }
904
905
1.79M
    void set_task_num(int task_num) { _task_num = task_num; }
906
907
52.0k
    int task_num() const { return _task_num; }
908
909
304k
    int profile_level() const { return _profile_level; }
910
911
22.7k
    std::shared_ptr<IdFileMap>& get_id_file_map() { return _id_file_map; }
912
913
    void set_id_file_map();
914
939k
    VectorSearchUserParams get_vector_search_params() const {
915
939k
        VectorSearchUserParams params;
916
939k
        params.hnsw_ef_search = _query_options.hnsw_ef_search;
917
939k
        params.hnsw_check_relative_distance = _query_options.hnsw_check_relative_distance;
918
939k
        params.hnsw_bounded_queue = _query_options.hnsw_bounded_queue;
919
939k
        params.ivf_nprobe = _query_options.ivf_nprobe;
920
939k
        params.ann_index_candidate_rows_threshold =
921
939k
                _query_options.__isset.ann_index_candidate_rows_threshold
922
939k
                        ? _query_options.ann_index_candidate_rows_threshold
923
939k
                        : 0;
924
939k
        params.ann_index_candidate_rows_percent_threshold =
925
939k
                _query_options.__isset.ann_index_candidate_rows_percent_threshold
926
939k
                        ? _query_options.ann_index_candidate_rows_percent_threshold
927
939k
                        : 0.3;
928
939k
        return params;
929
939k
    }
930
931
137
    bool runtime_filter_wait_infinitely() const {
932
137
        return _query_options.__isset.runtime_filter_wait_infinitely &&
933
137
               _query_options.runtime_filter_wait_infinitely;
934
137
    }
935
936
    const std::set<int>& get_deregister_runtime_filter() const;
937
938
    void merge_register_runtime_filter(const std::set<int>& runtime_filter_ids);
939
940
private:
941
    friend class ExternalFileReportReservation;
942
943
    void release_external_file_report_reservation(size_t reserved_bytes);
944
945
    Status create_error_log_file();
946
947
    static const int DEFAULT_BATCH_SIZE = 4062;
948
949
    std::shared_ptr<MemTrackerLimiter> _query_mem_tracker = nullptr;
950
951
    // Could not find a better way to record if the weak ptr is inited, use a bool to record
952
    // it. In some unit test cases, the runtime state's task ctx is not inited, then the test
953
    // hang, it is very hard to debug.
954
    bool _task_execution_context_inited = false;
955
    // Hold execution context for other threads
956
    std::weak_ptr<TaskExecutionContext> _task_execution_context;
957
958
    // put runtime state before _obj_pool, so that it will be deconstructed after
959
    // _obj_pool. Because some of object in _obj_pool will use profile when deconstructing.
960
    RuntimeProfile _profile;
961
    RuntimeProfile _load_channel_profile;
962
    // Why 2?
963
    // During cluster upgrade, fe will not pass profile_level to be, so we need to set it to 2
964
    // to make sure user can see all profile counters like before.
965
    int _profile_level = 2;
966
967
    const DescriptorTbl* _desc_tbl = nullptr;
968
    std::shared_ptr<ObjectPool> _obj_pool;
969
970
    // owned by PipelineFragmentContext
971
    RuntimeFilterMgr* _runtime_filter_mgr = nullptr;
972
973
    // Lock protecting _error_log and _unreported_error_idx
974
    std::mutex _error_log_lock;
975
976
    // Logs error messages.
977
    std::vector<std::string> _error_log;
978
979
    // _error_log[_unreported_error_idx+] has been not reported to the coordinator.
980
    int _unreported_error_idx;
981
982
    //Query-global timestamp_ms
983
    int64_t _timestamp_ms;
984
    int32_t _nano_seconds;
985
    std::string _timezone;
986
    cctz::time_zone _timezone_obj;
987
    std::string _lc_time_names;
988
989
    TUniqueId _query_id;
990
    // fragment id for each TPipelineFragmentParams
991
    int32_t _fragment_id;
992
    TUniqueId _fragment_instance_id;
993
    TQueryOptions _query_options;
994
    ExecEnv* _exec_env = nullptr;
995
996
    AtomicStatus _exec_status;
997
998
    int _per_fragment_instance_idx;
999
    int _num_per_fragment_instances = 0;
1000
    int _load_stream_per_node = 0;
1001
    int _total_load_streams = 0;
1002
    int _num_local_sink = 0;
1003
1004
    // The backend id on which this fragment instance runs
1005
    int64_t _backend_id = -1;
1006
1007
    // used as send id
1008
    int _be_number;
1009
1010
    // put here to collect files??
1011
    std::vector<std::string> _output_files;
1012
    std::atomic<int64_t> _num_rows_load_total;      // total rows read from source
1013
    std::atomic<int64_t> _num_rows_load_filtered;   // unqualified rows
1014
    std::atomic<int64_t> _num_rows_load_unselected; // rows filtered by predicates
1015
    std::atomic<int64_t> _num_rows_filtered_in_strict_mode_partial_update;
1016
    std::atomic<int64_t> _num_print_error_rows;
1017
1018
    std::atomic<int64_t> _num_bytes_load_total; // total bytes read from source
1019
    std::atomic<int64_t> _num_finished_scan_range;
1020
1021
    std::vector<std::string> _export_output_files;
1022
    std::string _import_label;
1023
    std::string _db_name;
1024
    std::string _load_dir;
1025
    int64_t _load_job_id;
1026
    int64_t _wal_id = -1;
1027
    size_t _content_length = 0;
1028
1029
    // mini load
1030
    std::string _error_log_file_path;
1031
    std::unique_ptr<std::ofstream> _error_log_file; // error file path, absolute path
1032
    std::string _first_error_msg = "";
1033
    mutable std::mutex _tablet_infos_mutex;
1034
    std::vector<TTabletCommitInfo> _tablet_commit_infos;
1035
    std::vector<TErrorTabletInfo> _error_tablet_infos;
1036
    int _max_operator_id = 0;
1037
    int _task_id = -1;
1038
    int _task_num = 0;
1039
1040
    mutable std::mutex _hive_partition_updates_mutex;
1041
    std::vector<THivePartitionUpdate> _hive_partition_updates;
1042
1043
    mutable std::mutex _iceberg_commit_datas_mutex;
1044
    std::vector<TIcebergCommitData> _iceberg_commit_datas;
1045
    std::shared_ptr<ExternalFileReportState> _external_file_report_state =
1046
            std::make_shared<ExternalFileReportState>();
1047
1048
    mutable std::mutex _mc_commit_datas_mutex;
1049
    std::vector<TMCCommitData> _mc_commit_datas;
1050
1051
    mutable std::mutex _paimon_commit_messages_mutex;
1052
    std::vector<TPaimonCommitMessage> _paimon_commit_messages;
1053
1054
    std::vector<std::unique_ptr<doris::PipelineXLocalStateBase>> _op_id_to_local_state;
1055
1056
    std::unique_ptr<doris::PipelineXSinkLocalStateBase> _sink_local_state;
1057
1058
    QueryContext* _query_ctx = nullptr;
1059
1060
    // true if max_filter_ratio is 0
1061
    bool _load_zero_tolerance = false;
1062
1063
    // only to lock _pipeline_id_to_profile
1064
    std::shared_mutex _pipeline_profile_lock;
1065
    std::vector<std::shared_ptr<RuntimeProfile>> _pipeline_id_to_profile;
1066
1067
    // save error log to s3
1068
    std::shared_ptr<io::S3FileSystem> _s3_error_fs;
1069
    // error file path on s3, ${bucket}/${prefix}/error_log/${label}_${fragment_instance_id}
1070
    std::string _s3_error_log_file_path;
1071
    // Protects the load error log stream, paths, and first error message.
1072
    mutable std::mutex _load_error_log_lock;
1073
    // Serializes S3 upload and presigned URL publication.
1074
    std::mutex _s3_error_log_file_lock;
1075
1076
    // used for encoding the global lazy materialize
1077
    std::shared_ptr<IdFileMap> _id_file_map = nullptr;
1078
1079
    std::set<int> _registered_runtime_filter_ids;
1080
};
1081
1082
#define RETURN_IF_CANCELLED(state)               \
1083
639k
    do {                                         \
1084
639k
        if (UNLIKELY((state)->is_cancelled())) { \
1085
16
            return (state)->cancel_reason();     \
1086
16
        }                                        \
1087
639k
    } while (false)
1088
1089
} // namespace doris