be/src/runtime/exec_env.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/olap_file.pb.h> |
21 | | |
22 | | #include <atomic> |
23 | | #include <map> |
24 | | #include <memory> |
25 | | #include <mutex> |
26 | | #include <optional> |
27 | | #include <string> |
28 | | #include <vector> |
29 | | |
30 | | #include "common/config.h" |
31 | | #include "common/multi_version.h" |
32 | | #include "common/status.h" |
33 | | #include "exec/pipeline/pipeline_tracing.h" |
34 | | #include "information_schema/schema_routine_load_job_scanner.h" |
35 | | #include "io/cache/fs_file_cache_storage.h" |
36 | | #include "load/memtable/memtable_memory_limiter.h" |
37 | | #include "runtime/cluster_info.h" |
38 | | #include "runtime/frontend_info.h" // TODO(zhiqiang): find a way to remove this include header |
39 | | #include "storage/index/inverted/inverted_index_writer.h" |
40 | | #include "storage/options.h" |
41 | | #include "storage/tablet/tablet_fwd.h" |
42 | | #include "util/threadpool.h" |
43 | | |
44 | | namespace orc { |
45 | | class MemoryPool; |
46 | | } |
47 | | namespace arrow { |
48 | | class MemoryPool; |
49 | | } |
50 | | |
51 | | namespace doris { |
52 | | class VDataStreamMgr; |
53 | | class SpillFileManager; |
54 | | class DeltaWriterV2Pool; |
55 | | class DictionaryFactory; |
56 | | class TaskScheduler; |
57 | | struct RuntimeFilterTimerQueue; |
58 | | class WorkloadGroupMgr; |
59 | | struct WriteCooldownMetaExecutors; |
60 | | class TokenBucketRateLimiterHolder; |
61 | | using S3RateLimiterHolder = TokenBucketRateLimiterHolder; |
62 | | namespace io { |
63 | | class FileCacheFactory; |
64 | | class HdfsMgr; |
65 | | class PackedFileManager; |
66 | | } // namespace io |
67 | | |
68 | | namespace cloud { |
69 | | class HostLevelMSRpcRateLimiters; |
70 | | class TableRpcQpsRegistry; |
71 | | class TableRpcThrottler; |
72 | | class MSBackpressureHandler; |
73 | | } // namespace cloud |
74 | | |
75 | | namespace segment_v2 { |
76 | | class InvertedIndexSearcherCache; |
77 | | class InvertedIndexQueryCache; |
78 | | class ConditionCache; |
79 | | class TmpFileDirs; |
80 | | class EncodingInfoResolver; |
81 | | |
82 | | namespace inverted_index { |
83 | | class AnalysisFactoryMgr; |
84 | | } |
85 | | |
86 | | } // namespace segment_v2 |
87 | | |
88 | | namespace kerberos { |
89 | | class KerberosTicketMgr; |
90 | | } |
91 | | |
92 | | class QueryCache; |
93 | | class WorkloadSchedPolicyMgr; |
94 | | class BfdParser; |
95 | | class BrokerMgr; |
96 | | template <class T> |
97 | | class BrpcClientCache; |
98 | | class ExternalScanContextMgr; |
99 | | class FragmentMgr; |
100 | | class ResultCache; |
101 | | class LoadPathMgr; |
102 | | class NewLoadStreamMgr; |
103 | | class MemTrackerLimiter; |
104 | | class MemTracker; |
105 | | struct TrackerLimiterGroup; |
106 | | class BaseStorageEngine; |
107 | | class ResultBufferMgr; |
108 | | class ResultQueueMgr; |
109 | | class RuntimeQueryStatisticsMgr; |
110 | | class LoadChannelMgr; |
111 | | class LoadStreamMgr; |
112 | | class LoadStreamMapPool; |
113 | | class StreamLoadExecutor; |
114 | | class RoutineLoadTaskExecutor; |
115 | | class StreamLoadRecorderManager; |
116 | | class SmallFileMgr; |
117 | | class BackendServiceClient; |
118 | | class TPaloBrokerServiceClient; |
119 | | class PBackendService_Stub; |
120 | | class PFunctionService_Stub; |
121 | | template <class T> |
122 | | class ClientCache; |
123 | | class HeartbeatFlags; |
124 | | class FrontendServiceClient; |
125 | | class FileMetaCache; |
126 | | class GroupCommitMgr; |
127 | | class CdcClientMgr; |
128 | | class TabletSchemaCache; |
129 | | class TabletColumnObjectPool; |
130 | | class UserFunctionCache; |
131 | | class SchemaCache; |
132 | | class StoragePageCache; |
133 | | class AnnIndexIVFListCache; |
134 | | class SegmentLoader; |
135 | | class LookupConnectionCache; |
136 | | class RowCache; |
137 | | class DummyLRUCache; |
138 | | class CacheManager; |
139 | | class IdManager; |
140 | | class ProcessProfile; |
141 | | class HeapProfiler; |
142 | | class WalManager; |
143 | | class DNSCache; |
144 | | class IndexPolicyMgr; |
145 | | struct SyncRowsetStats; |
146 | | class DeleteBitmapAggCache; |
147 | | |
148 | | // set to true when BE is shutting down |
149 | | inline bool k_doris_exit = false; |
150 | | // set to true after BE start ready |
151 | | inline bool k_is_server_ready = false; |
152 | | |
153 | | // Execution environment for queries/plan fragments. |
154 | | // Contains all required global structures, and handles to |
155 | | // singleton services. Clients must call StartServices exactly |
156 | | // once to properly initialise service state. |
157 | | class ExecEnv { |
158 | | public: |
159 | | // Empty destructor because the compiler-generated one requires full |
160 | | // declarations for classes in scoped_ptrs. |
161 | | ~ExecEnv(); |
162 | 1.83M | |
163 | | BaseStorageEngine& storage_engine() { return *_storage_engine; } |
164 | | |
165 | | // Initial exec environment. must call this to init all |
166 | | [[nodiscard]] static Status init(ExecEnv* env, const std::vector<StorePath>& store_paths, |
167 | | const std::vector<StorePath>& spill_store_paths, |
168 | | const std::set<std::string>& broken_paths); |
169 | | |
170 | | // Stop all threads and delete resources. |
171 | | void destroy(); |
172 | | |
173 | | /// Returns the first created exec env instance. In a normal doris, this is |
174 | | /// the only instance. In test setups with multiple ExecEnv's per process, |
175 | 366M | /// we return the most recently created instance. |
176 | 366M | static ExecEnv* GetInstance() { |
177 | 366M | static ExecEnv s_exec_env; |
178 | 366M | return &s_exec_env; |
179 | | } |
180 | | |
181 | | // Requires ExenEnv ready |
182 | | /* |
183 | | * Parameters: |
184 | | * - tablet_id: the id of tablet to get |
185 | | * - sync_stats: the stats of sync rowset |
186 | | * - force_use_only_cached: whether only use cached data |
187 | | * - cache_on_miss: whether cache the tablet meta when missing in cache |
188 | | */ |
189 | | static Result<BaseTabletSPtr> get_tablet(int64_t tablet_id, |
190 | | SyncRowsetStats* sync_stats = nullptr, |
191 | | bool force_use_only_cached = false, |
192 | | bool cache_on_miss = true); |
193 | | |
194 | | static Status get_tablet_meta(int64_t tablet_id, TabletMetaSharedPtr* tablet_meta, |
195 | | bool force_use_only_cached = false); |
196 | 608k | |
197 | 994k | static bool ready() { return _s_ready.load(std::memory_order_acquire); } |
198 | 1.87k | static bool tracking_memory() { return _s_tracking_memory.load(std::memory_order_acquire); } |
199 | 0 | static bool get_is_upgrading() { return _s_upgrading.load(std::memory_order_acquire); } |
200 | | static void set_is_upgrading() { _s_upgrading = true; } |
201 | 10 | const std::string& token() const; |
202 | 5.44M | ExternalScanContextMgr* external_scan_context_mgr() { return _external_scan_context_mgr; } |
203 | 907k | VDataStreamMgr* vstream_mgr() { return _vstream_mgr; } |
204 | 12 | ResultBufferMgr* result_mgr() { return _result_mgr; } |
205 | 0 | ResultQueueMgr* result_queue_mgr() { return _result_queue_mgr; } |
206 | 51.1k | ClientCache<BackendServiceClient>* client_cache() { return _backend_client_cache; } |
207 | 210 | ClientCache<FrontendServiceClient>* frontend_client_cache() { return _frontend_client_cache; } |
208 | | ClientCache<TPaloBrokerServiceClient>* broker_client_cache() { return _broker_client_cache; } |
209 | 1.01M | |
210 | 1.46k | WorkloadGroupMgr* workload_group_mgr() { return _workload_group_manager; } |
211 | 292k | WorkloadSchedPolicyMgr* workload_sched_policy_mgr() { return _workload_sched_mgr; } |
212 | 292k | RuntimeQueryStatisticsMgr* runtime_query_statistics_mgr() { |
213 | 292k | return _runtime_query_statistics_mgr; |
214 | | } |
215 | | |
216 | | // using template to simplify client cache management |
217 | | template <typename T> |
218 | | inline ClientCache<T>* get_client_cache() { |
219 | | return nullptr; |
220 | | } |
221 | | |
222 | | // Save all MemTrackerLimiters in use. |
223 | | // Each group corresponds to several MemTrackerLimiters and has a lock. |
224 | | // Multiple groups are used to reduce the impact of locks. |
225 | | std::vector<TrackerLimiterGroup> mem_tracker_limiter_pool; |
226 | 7.87M | void init_mem_tracker(); |
227 | 238k | std::shared_ptr<MemTrackerLimiter> orphan_mem_tracker() { return _orphan_mem_tracker; } |
228 | 238k | std::shared_ptr<MemTrackerLimiter> brpc_iobuf_block_memory_tracker() { |
229 | 238k | return _brpc_iobuf_block_memory_tracker; |
230 | 0 | } |
231 | 0 | std::shared_ptr<MemTrackerLimiter> segcompaction_mem_tracker() { |
232 | 0 | return _segcompaction_mem_tracker; |
233 | 303k | } |
234 | 303k | std::shared_ptr<MemTrackerLimiter> stream_load_pipe_tracker() { |
235 | 303k | return _stream_load_pipe_tracker; |
236 | 1.00k | } |
237 | 1.00k | std::shared_ptr<MemTrackerLimiter> tablets_no_cache_mem_tracker() { |
238 | 1.00k | return _tablets_no_cache_mem_tracker; |
239 | 1.00k | } |
240 | 1.00k | std::shared_ptr<MemTrackerLimiter> rowsets_no_cache_mem_tracker() { |
241 | 1.00k | return _rowsets_no_cache_mem_tracker; |
242 | 1.00k | } |
243 | 1.00k | std::shared_ptr<MemTrackerLimiter> segments_no_cache_mem_tracker() { |
244 | 1.00k | return _segments_no_cache_mem_tracker; |
245 | 2.88k | } |
246 | 2.88k | std::shared_ptr<MemTrackerLimiter> point_query_executor_mem_tracker() { |
247 | 2.88k | return _point_query_executor_mem_tracker; |
248 | 68 | } |
249 | 68 | std::shared_ptr<MemTrackerLimiter> query_cache_mem_tracker() { |
250 | 68 | return _query_cache_mem_tracker; |
251 | 396k | } |
252 | 396k | std::shared_ptr<MemTrackerLimiter> block_compression_mem_tracker() { |
253 | 396k | return _block_compression_mem_tracker; |
254 | 7.45k | } |
255 | 7.45k | std::shared_ptr<MemTrackerLimiter> rowid_storage_reader_tracker() { |
256 | 7.45k | return _rowid_storage_reader_tracker; |
257 | 63.3k | } |
258 | 63.3k | std::shared_ptr<MemTrackerLimiter> subcolumns_tree_tracker() { |
259 | 63.3k | return _subcolumns_tree_tracker; |
260 | 140k | } |
261 | 22.3k | std::shared_ptr<MemTrackerLimiter> s3_file_buffer_tracker() { return _s3_file_buffer_tracker; } |
262 | | std::shared_ptr<MemTrackerLimiter> parquet_meta_tracker() { return _parquet_meta_tracker; } |
263 | 53.4k | |
264 | 176 | ThreadPool* send_batch_thread_pool() { return _send_batch_thread_pool.get(); } |
265 | 176 | ThreadPool* buffered_reader_prefetch_thread_pool() { |
266 | 176 | return _buffered_reader_prefetch_thread_pool.get(); |
267 | 6.96k | } |
268 | 71.4k | ThreadPool* send_table_stats_thread_pool() { return _send_table_stats_thread_pool.get(); } |
269 | 0 | ThreadPool* s3_file_upload_thread_pool() { return _s3_file_upload_thread_pool.get(); } |
270 | | ThreadPool* lazy_release_obj_pool() { return _lazy_release_obj_pool.get(); } |
271 | 0 | ThreadPool* non_block_close_thread_pool(); |
272 | 0 | ThreadPool* s3_file_system_thread_pool() { return _s3_file_system_thread_pool.get(); } |
273 | 1.15M | ThreadPool* udf_close_workers_pool() { return _udf_close_workers_thread_pool.get(); } |
274 | | ThreadPool* segment_prefetch_thread_pool() { return _segment_prefetch_thread_pool.get(); } |
275 | | |
276 | 407k | void init_file_cache_factory(std::vector<doris::CachePath>& cache_paths); |
277 | 7.12k | io::FileCacheFactory* file_cache_factory() { return _file_cache_factory; } |
278 | 2.17M | UserFunctionCache* user_function_cache() { return _user_function_cache; } |
279 | 67.3k | FragmentMgr* fragment_mgr() { return _fragment_mgr; } |
280 | 283M | ResultCache* result_cache() { return _result_cache; } |
281 | 1.76k | ClusterInfo* cluster_info() { return _cluster_info; } |
282 | 8 | LoadPathMgr* load_path_mgr() { return _load_path_mgr; } |
283 | 2 | BfdParser* bfd_parser() const { return _bfd_parser; } |
284 | 1.88M | BrokerMgr* broker_mgr() const { return _broker_mgr; } |
285 | 1.88M | BrpcClientCache<PBackendService_Stub>* brpc_internal_client_cache() const { |
286 | 1.88M | return _internal_client_cache; |
287 | 5.52k | } |
288 | 5.52k | BrpcClientCache<PBackendService_Stub>* brpc_streaming_client_cache() const { |
289 | 5.52k | return _streaming_client_cache; |
290 | 0 | } |
291 | 0 | BrpcClientCache<PFunctionService_Stub>* brpc_function_client_cache() const { |
292 | 0 | return _function_client_cache; |
293 | 111k | } |
294 | 4.07k | LoadChannelMgr* load_channel_mgr() { return _load_channel_mgr; } |
295 | 15.5k | LoadStreamMgr* load_stream_mgr() { return _load_stream_mgr.get(); } |
296 | 0 | NewLoadStreamMgr* new_load_stream_mgr() { return _new_load_stream_mgr.get(); } |
297 | | SmallFileMgr* small_file_mgr() { return _small_file_mgr; } |
298 | 1.91k | |
299 | | SpillFileManager* spill_file_mgr() { return _spill_file_mgr; } |
300 | 317 | |
301 | 1.18k | GroupCommitMgr* group_commit_mgr() { return _group_commit_mgr; } |
302 | | CdcClientMgr* cdc_client_mgr() { return _cdc_client_mgr; } |
303 | 33 | |
304 | | const std::vector<StorePath>& store_paths() const { return _store_paths; } |
305 | 7.04k | |
306 | 3.04k | StreamLoadExecutor* stream_load_executor() { return _stream_load_executor.get(); } |
307 | 1.32k | RoutineLoadTaskExecutor* routine_load_task_executor() { return _routine_load_task_executor; } |
308 | 125k | HeartbeatFlags* heartbeat_flags() { return _heartbeat_flags; } |
309 | 396k | FileMetaCache* file_meta_cache() { return _file_meta_cache; } |
310 | 2.36k | MemTableMemoryLimiter* memtable_memory_limiter() { return _memtable_memory_limiter.get(); } |
311 | 2.01M | WalManager* wal_mgr() { return _wal_manager.get(); } |
312 | 7 | DNSCache* dns_cache() { return _dns_cache; } |
313 | 7 | WriteCooldownMetaExecutors* write_cooldown_meta_executors() { |
314 | 7 | return _write_cooldown_meta_executors.get(); |
315 | | } |
316 | 1 | |
317 | 43.4k | kerberos::KerberosTicketMgr* kerberos_ticket_mgr() { return _kerberos_ticket_mgr; } |
318 | 0 | io::HdfsMgr* hdfs_mgr() { return _hdfs_mgr; } |
319 | 1.83k | io::PackedFileManager* packed_file_manager() { return _packed_file_manager; } |
320 | 1.98k | IndexPolicyMgr* index_policy_mgr() { return _index_policy_mgr; } |
321 | 0 | S3RateLimiterHolder* warmup_download_rate_limiter() { return _warmup_download_rate_limiter; } |
322 | 0 | cloud::HostLevelMSRpcRateLimiters* host_level_ms_rpc_rate_limiters() { |
323 | 0 | return _host_level_ms_rpc_rate_limiters.get(); |
324 | 0 | } |
325 | 1 | cloud::TableRpcQpsRegistry* table_rpc_qps_registry() { return _table_rpc_qps_registry.get(); } |
326 | 0 | cloud::TableRpcThrottler* table_rpc_throttler() { return _table_rpc_throttler.get(); } |
327 | 0 | cloud::MSBackpressureHandler* ms_backpressure_handler() { |
328 | 0 | return _ms_backpressure_handler.get(); |
329 | | } |
330 | | |
331 | | #ifdef BE_TEST |
332 | | void set_tmp_file_dir(std::unique_ptr<segment_v2::TmpFileDirs> tmp_file_dirs) { |
333 | | this->_tmp_file_dirs = std::move(tmp_file_dirs); |
334 | | } |
335 | | void set_ready() { this->_s_ready = true; } |
336 | | void set_not_ready() { this->_s_ready = false; } |
337 | | void set_memtable_memory_limiter(MemTableMemoryLimiter* limiter) { |
338 | | _memtable_memory_limiter.reset(limiter); |
339 | | } |
340 | | void set_cluster_info(ClusterInfo* cluster_info) { this->_cluster_info = cluster_info; } |
341 | | void set_new_load_stream_mgr(std::unique_ptr<NewLoadStreamMgr>&& new_load_stream_mgr); |
342 | | void clear_new_load_stream_mgr(); |
343 | | void set_stream_load_executor(std::unique_ptr<StreamLoadExecutor>&& stream_load_executor); |
344 | | void clear_stream_load_executor(); |
345 | | |
346 | | void set_storage_engine(std::unique_ptr<BaseStorageEngine>&& engine); |
347 | | void set_inverted_index_searcher_cache( |
348 | | segment_v2::InvertedIndexSearcherCache* inverted_index_searcher_cache); |
349 | | void set_inverted_index_query_cache( |
350 | | segment_v2::InvertedIndexQueryCache* inverted_index_query_cache) { |
351 | | _inverted_index_query_cache = inverted_index_query_cache; |
352 | | } |
353 | | void set_cache_manager(CacheManager* cm) { this->_cache_manager = cm; } |
354 | | void set_process_profile(ProcessProfile* pp) { this->_process_profile = pp; } |
355 | | void set_tablet_schema_cache(TabletSchemaCache* c) { this->_tablet_schema_cache = c; } |
356 | | void set_delete_bitmap_agg_cache(DeleteBitmapAggCache* c) { _delete_bitmap_agg_cache = c; } |
357 | | void set_tablet_column_object_pool(TabletColumnObjectPool* c) { |
358 | | this->_tablet_column_object_pool = c; |
359 | | } |
360 | | void set_storage_page_cache(StoragePageCache* c) { this->_storage_page_cache = c; } |
361 | | void set_ann_index_ivf_list_cache(AnnIndexIVFListCache* c) { |
362 | | this->_ann_index_ivf_list_cache = c; |
363 | | } |
364 | | void set_segment_loader(SegmentLoader* sl) { this->_segment_loader = sl; } |
365 | | void set_routine_load_task_executor(RoutineLoadTaskExecutor* r) { |
366 | | this->_routine_load_task_executor = r; |
367 | | } |
368 | | void set_wal_mgr(std::unique_ptr<WalManager>&& wm); |
369 | | void clear_wal_mgr(); |
370 | | |
371 | | void set_write_cooldown_meta_executors(); |
372 | | static void set_tracking_memory(bool tracking_memory) { |
373 | | _s_tracking_memory.store(tracking_memory, std::memory_order_release); |
374 | | } |
375 | | void set_orc_memory_pool(orc::MemoryPool* pool) { _orc_memory_pool = pool; } |
376 | | void set_non_block_close_thread_pool(std::unique_ptr<ThreadPool>&& pool) { |
377 | | _non_block_close_thread_pool = std::move(pool); |
378 | | } |
379 | | void set_s3_file_upload_thread_pool(std::unique_ptr<ThreadPool>&& pool) { |
380 | | _s3_file_upload_thread_pool = std::move(pool); |
381 | | } |
382 | | void set_file_cache_factory(io::FileCacheFactory* factory) { _file_cache_factory = factory; } |
383 | 5.52k | void set_file_cache_open_fd_cache(std::unique_ptr<io::FDCache>&& fd_cache) { |
384 | | _file_cache_open_fd_cache = std::move(fd_cache); |
385 | 5.49k | } |
386 | | #endif |
387 | | LoadStreamMapPool* load_stream_map_pool() { return _load_stream_map_pool.get(); } |
388 | | |
389 | | DeltaWriterV2Pool* delta_writer_v2_pool() { return _delta_writer_v2_pool.get(); } |
390 | | |
391 | | void wait_for_all_tasks_done(); |
392 | | |
393 | 3.05M | void update_frontends(const std::vector<TFrontendInfo>& new_infos); |
394 | 5.16M | std::vector<TFrontendInfo> get_frontends(); |
395 | 2.60M | std::map<TNetworkAddress, FrontendInfo> get_running_frontends(); |
396 | 12.0M | |
397 | 2.39M | TabletSchemaCache* get_tablet_schema_cache() { return _tablet_schema_cache; } |
398 | 358 | TabletColumnObjectPool* get_tablet_column_object_pool() { return _tablet_column_object_pool; } |
399 | 299 | SchemaCache* schema_cache() { return _schema_cache; } |
400 | 2.69k | StoragePageCache* get_storage_page_cache() { return _storage_page_cache; } |
401 | 120k | AnnIndexIVFListCache* get_ann_index_ivf_list_cache() { return _ann_index_ivf_list_cache; } |
402 | 2.03k | SegmentLoader* segment_loader() { return _segment_loader; } |
403 | 0 | LookupConnectionCache* get_lookup_connection_cache() { return _lookup_connection_cache; } |
404 | 108k | RowCache* get_row_cache() { return _row_cache; } |
405 | 108k | CacheManager* get_cache_manager() { return _cache_manager; } |
406 | 108k | IdManager* get_id_manager() { return _id_manager; } |
407 | 26.8k | ProcessProfile* get_process_profile() { return _process_profile; } |
408 | 26.8k | HeapProfiler* get_heap_profiler() { return _heap_profiler; } |
409 | 26.8k | segment_v2::InvertedIndexSearcherCache* get_inverted_index_searcher_cache() { |
410 | 3.25M | return _inverted_index_searcher_cache; |
411 | 5.56M | } |
412 | 5.56M | segment_v2::InvertedIndexQueryCache* get_inverted_index_query_cache() { |
413 | 5.56M | return _inverted_index_query_cache; |
414 | 31 | } |
415 | | segment_v2::ConditionCache* get_condition_cache() { return _condition_cache; } |
416 | 24.6k | segment_v2::EncodingInfoResolver* get_encoding_info_resolver() { |
417 | | return _encoding_info_resolver; |
418 | 3.21k | } |
419 | | QueryCache* get_query_cache() { return _query_cache; } |
420 | 7.66M | |
421 | | RuntimeFilterTimerQueue* runtime_filter_timer_queue() { return _runtime_filter_timer_queue; } |
422 | 6.66k | |
423 | 2.54M | DictionaryFactory* dict_factory() { return _dict_factory; } |
424 | | |
425 | 31.6k | PipelineTracerContext* pipeline_tracer_context() { return _pipeline_tracer_ctx.get(); } |
426 | 8.24k | |
427 | | segment_v2::TmpFileDirs* get_tmp_file_dirs() { return _tmp_file_dirs.get(); } |
428 | | io::FDCache* file_cache_open_fd_cache() const { return _file_cache_open_fd_cache.get(); } |
429 | 10 | |
430 | | orc::MemoryPool* orc_memory_pool() { return _orc_memory_pool; } |
431 | | arrow::MemoryPool* arrow_memory_pool() { return _arrow_memory_pool; } |
432 | 12.0M | |
433 | | bool check_auth_token(const std::string& auth_token); |
434 | | void set_stream_mgr(VDataStreamMgr* vstream_mgr) { _vstream_mgr = vstream_mgr; } |
435 | | void clear_stream_mgr(); |
436 | | |
437 | | DeleteBitmapAggCache* delete_bitmap_agg_cache() { return _delete_bitmap_agg_cache; } |
438 | | Status init_mem_env(); |
439 | | |
440 | | private: |
441 | | ExecEnv(); |
442 | | |
443 | | [[nodiscard]] Status _init(const std::vector<StorePath>& store_paths, |
444 | | const std::vector<StorePath>& spill_store_paths, |
445 | | const std::set<std::string>& broken_paths); |
446 | | void _destroy(); |
447 | | |
448 | | Status _check_deploy_mode(); |
449 | | |
450 | | Status _create_internal_workload_group(); |
451 | | void _init_runtime_filter_timer_queue(); |
452 | | |
453 | | inline static std::atomic_bool _s_ready {false}; |
454 | | inline static std::atomic_bool _s_tracking_memory {false}; |
455 | | std::vector<StorePath> _store_paths; |
456 | | std::vector<StorePath> _spill_store_paths; |
457 | | inline static std::atomic_bool _s_upgrading {false}; |
458 | | |
459 | | io::FileCacheFactory* _file_cache_factory = nullptr; |
460 | | UserFunctionCache* _user_function_cache = nullptr; |
461 | | // Leave protected so that subclasses can override |
462 | | ExternalScanContextMgr* _external_scan_context_mgr = nullptr; |
463 | | VDataStreamMgr* _vstream_mgr = nullptr; |
464 | | ResultBufferMgr* _result_mgr = nullptr; |
465 | | ResultQueueMgr* _result_queue_mgr = nullptr; |
466 | | ClientCache<BackendServiceClient>* _backend_client_cache = nullptr; |
467 | | ClientCache<FrontendServiceClient>* _frontend_client_cache = nullptr; |
468 | | ClientCache<TPaloBrokerServiceClient>* _broker_client_cache = nullptr; |
469 | | |
470 | | // The default tracker consumed by mem hook. If the thread does not attach other trackers, |
471 | | // by default all consumption will be passed to the process tracker through the orphan tracker. |
472 | | // In real time, `consumption of all limiter trackers` + `orphan tracker consumption` = `process tracker consumption`. |
473 | | // Ideally, all threads are expected to attach to the specified tracker, so that "all memory has its own ownership", |
474 | | // and the consumption of the orphan mem tracker is close to 0, but greater than 0. |
475 | | std::shared_ptr<MemTrackerLimiter> _orphan_mem_tracker; |
476 | | std::shared_ptr<MemTrackerLimiter> _brpc_iobuf_block_memory_tracker; |
477 | | // Count the memory consumption of segment compaction tasks. |
478 | | std::shared_ptr<MemTrackerLimiter> _segcompaction_mem_tracker; |
479 | | std::shared_ptr<MemTrackerLimiter> _stream_load_pipe_tracker; |
480 | | |
481 | | std::shared_ptr<MemTrackerLimiter> _tablets_no_cache_mem_tracker; |
482 | | std::shared_ptr<MemTrackerLimiter> _rowsets_no_cache_mem_tracker; |
483 | | std::shared_ptr<MemTrackerLimiter> _segments_no_cache_mem_tracker; |
484 | | |
485 | | // Tracking memory may be shared between multiple queries. |
486 | | std::shared_ptr<MemTrackerLimiter> _point_query_executor_mem_tracker; |
487 | | std::shared_ptr<MemTrackerLimiter> _block_compression_mem_tracker; |
488 | | std::shared_ptr<MemTrackerLimiter> _query_cache_mem_tracker; |
489 | | |
490 | | // TODO, looking forward to more accurate tracking. |
491 | | std::shared_ptr<MemTrackerLimiter> _rowid_storage_reader_tracker; |
492 | | std::shared_ptr<MemTrackerLimiter> _subcolumns_tree_tracker; |
493 | | std::shared_ptr<MemTrackerLimiter> _s3_file_buffer_tracker; |
494 | | |
495 | | // Tracking memory consumption of parquet meta |
496 | | std::shared_ptr<MemTrackerLimiter> _parquet_meta_tracker; |
497 | | |
498 | | std::unique_ptr<ThreadPool> _send_batch_thread_pool; |
499 | | // Threadpool used to prefetch remote file for buffered reader |
500 | | std::unique_ptr<ThreadPool> _buffered_reader_prefetch_thread_pool; |
501 | | // Threadpool used to send TableStats to FE |
502 | | std::unique_ptr<ThreadPool> _send_table_stats_thread_pool; |
503 | | // Threadpool used to upload local file to s3 |
504 | | std::unique_ptr<ThreadPool> _s3_file_upload_thread_pool; |
505 | | // Pool used by join node to build hash table |
506 | | // Pool to use a new thread to release object |
507 | | std::unique_ptr<ThreadPool> _lazy_release_obj_pool; |
508 | | std::unique_ptr<ThreadPool> _non_block_close_thread_pool; |
509 | | std::unique_ptr<ThreadPool> _s3_file_system_thread_pool; |
510 | | // for java-udf to close |
511 | | std::unique_ptr<ThreadPool> _udf_close_workers_thread_pool; |
512 | | // Threadpool used to prefetch segment file cache blocks |
513 | | std::unique_ptr<ThreadPool> _segment_prefetch_thread_pool; |
514 | | |
515 | | FragmentMgr* _fragment_mgr = nullptr; |
516 | | WorkloadGroupMgr* _workload_group_manager = nullptr; |
517 | | |
518 | | ResultCache* _result_cache = nullptr; |
519 | | ClusterInfo* _cluster_info = nullptr; |
520 | | LoadPathMgr* _load_path_mgr = nullptr; |
521 | | |
522 | | BfdParser* _bfd_parser = nullptr; |
523 | | BrokerMgr* _broker_mgr = nullptr; |
524 | | LoadChannelMgr* _load_channel_mgr = nullptr; |
525 | | std::unique_ptr<LoadStreamMgr> _load_stream_mgr; |
526 | | std::unique_ptr<NewLoadStreamMgr> _new_load_stream_mgr; |
527 | | BrpcClientCache<PBackendService_Stub>* _internal_client_cache = nullptr; |
528 | | BrpcClientCache<PBackendService_Stub>* _streaming_client_cache = nullptr; |
529 | | BrpcClientCache<PFunctionService_Stub>* _function_client_cache = nullptr; |
530 | | |
531 | | std::unique_ptr<StreamLoadExecutor> _stream_load_executor; |
532 | | RoutineLoadTaskExecutor* _routine_load_task_executor = nullptr; |
533 | | StreamLoadRecorderManager* _stream_load_recorder_manager = nullptr; |
534 | | SmallFileMgr* _small_file_mgr = nullptr; |
535 | | HeartbeatFlags* _heartbeat_flags = nullptr; |
536 | | |
537 | | // To save meta info of external file, such as parquet footer. |
538 | | FileMetaCache* _file_meta_cache = nullptr; |
539 | | std::unique_ptr<MemTableMemoryLimiter> _memtable_memory_limiter; |
540 | | std::unique_ptr<LoadStreamMapPool> _load_stream_map_pool; |
541 | | std::unique_ptr<DeltaWriterV2Pool> _delta_writer_v2_pool; |
542 | | std::unique_ptr<WalManager> _wal_manager; |
543 | | DNSCache* _dns_cache = nullptr; |
544 | | std::unique_ptr<WriteCooldownMetaExecutors> _write_cooldown_meta_executors; |
545 | | |
546 | | std::mutex _frontends_lock; |
547 | | // ip:brpc_port -> frontend_indo |
548 | | std::map<TNetworkAddress, FrontendInfo> _frontends; |
549 | | GroupCommitMgr* _group_commit_mgr = nullptr; |
550 | | CdcClientMgr* _cdc_client_mgr = nullptr; |
551 | | |
552 | | // Maybe we should use unique_ptr, but it need complete type, which means we need |
553 | | // to include many headers, and for some cpp file that do not need class like TabletSchemaCache, |
554 | | // these redundancy header could introduce potential bug, at least, more header means slow compile. |
555 | | // So we choose to use raw pointer, please remember to delete these pointer in deconstructor. |
556 | | TabletSchemaCache* _tablet_schema_cache = nullptr; |
557 | | TabletColumnObjectPool* _tablet_column_object_pool = nullptr; |
558 | | std::unique_ptr<BaseStorageEngine> _storage_engine; |
559 | | SchemaCache* _schema_cache = nullptr; |
560 | | StoragePageCache* _storage_page_cache = nullptr; |
561 | | AnnIndexIVFListCache* _ann_index_ivf_list_cache = nullptr; |
562 | | SegmentLoader* _segment_loader = nullptr; |
563 | | LookupConnectionCache* _lookup_connection_cache = nullptr; |
564 | | RowCache* _row_cache = nullptr; |
565 | | CacheManager* _cache_manager = nullptr; |
566 | | IdManager* _id_manager = nullptr; |
567 | | ProcessProfile* _process_profile = nullptr; |
568 | | HeapProfiler* _heap_profiler = nullptr; |
569 | | segment_v2::InvertedIndexSearcherCache* _inverted_index_searcher_cache = nullptr; |
570 | | segment_v2::InvertedIndexQueryCache* _inverted_index_query_cache = nullptr; |
571 | | segment_v2::ConditionCache* _condition_cache = nullptr; |
572 | | segment_v2::EncodingInfoResolver* _encoding_info_resolver = nullptr; |
573 | | QueryCache* _query_cache = nullptr; |
574 | | std::unique_ptr<io::FDCache> _file_cache_open_fd_cache; |
575 | | DeleteBitmapAggCache* _delete_bitmap_agg_cache {nullptr}; |
576 | | |
577 | | RuntimeFilterTimerQueue* _runtime_filter_timer_queue = nullptr; |
578 | | DictionaryFactory* _dict_factory = nullptr; |
579 | | |
580 | | WorkloadSchedPolicyMgr* _workload_sched_mgr = nullptr; |
581 | | IndexPolicyMgr* _index_policy_mgr = nullptr; |
582 | | |
583 | | RuntimeQueryStatisticsMgr* _runtime_query_statistics_mgr = nullptr; |
584 | | |
585 | | std::unique_ptr<PipelineTracerContext> _pipeline_tracer_ctx; |
586 | | std::unique_ptr<segment_v2::TmpFileDirs> _tmp_file_dirs; |
587 | | |
588 | | SpillFileManager* _spill_file_mgr = nullptr; |
589 | | |
590 | | orc::MemoryPool* _orc_memory_pool = nullptr; |
591 | | arrow::MemoryPool* _arrow_memory_pool = nullptr; |
592 | | |
593 | | kerberos::KerberosTicketMgr* _kerberos_ticket_mgr = nullptr; |
594 | | io::HdfsMgr* _hdfs_mgr = nullptr; |
595 | | io::PackedFileManager* _packed_file_manager = nullptr; |
596 | | S3RateLimiterHolder* _warmup_download_rate_limiter = nullptr; |
597 | | |
598 | | std::unique_ptr<cloud::HostLevelMSRpcRateLimiters> _host_level_ms_rpc_rate_limiters; |
599 | 0 | std::unique_ptr<cloud::TableRpcQpsRegistry> _table_rpc_qps_registry; |
600 | 0 | std::unique_ptr<cloud::TableRpcThrottler> _table_rpc_throttler; |
601 | 0 | std::unique_ptr<cloud::MSBackpressureHandler> _ms_backpressure_handler; |
602 | | }; |
603 | 35.1k | |
604 | 35.1k | template <> |
605 | 35.1k | inline ClientCache<BackendServiceClient>* ExecEnv::get_client_cache<BackendServiceClient>() { |
606 | | return _backend_client_cache; |
607 | | } |
608 | 0 | template <> |
609 | 0 | inline ClientCache<FrontendServiceClient>* ExecEnv::get_client_cache<FrontendServiceClient>() { |
610 | 0 | return _frontend_client_cache; |
611 | | } |
612 | 0 | template <> |
613 | 0 | inline ClientCache<TPaloBrokerServiceClient>* |
614 | 0 | ExecEnv::get_client_cache<TPaloBrokerServiceClient>() { |
615 | | return _broker_client_cache; |
616 | | } |
617 | | |
618 | | inline segment_v2::InvertedIndexQueryCache* GetInvertedIndexQueryCache() { |
619 | | return ExecEnv::GetInstance()->get_inverted_index_query_cache(); |
620 | | } |
621 | | |
622 | | } // namespace doris |