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