Coverage Report

Created: 2026-03-12 15:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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 SpillStreamManager;
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 SegmentLoader;
134
class LookupConnectionCache;
135
class RowCache;
136
class DummyLRUCache;
137
class CacheManager;
138
class IdManager;
139
class ProcessProfile;
140
class HeapProfiler;
141
class WalManager;
142
class DNSCache;
143
class IndexPolicyMgr;
144
struct SyncRowsetStats;
145
class DeleteBitmapAggCache;
146
147
// set to true when BE is shutting down
148
inline bool k_doris_exit = false;
149
// set to true after BE start ready
150
inline bool k_is_server_ready = false;
151
152
// Execution environment for queries/plan fragments.
153
// Contains all required global structures, and handles to
154
// singleton services. Clients must call StartServices exactly
155
// once to properly initialise service state.
156
class ExecEnv {
157
public:
158
    // Empty destructor because the compiler-generated one requires full
159
    // declarations for classes in scoped_ptrs.
160
    ~ExecEnv();
161
162
2.36M
    BaseStorageEngine& storage_engine() { return *_storage_engine; }
163
164
    // Initial exec environment. must call this to init all
165
    [[nodiscard]] static Status init(ExecEnv* env, const std::vector<StorePath>& store_paths,
166
                                     const std::vector<StorePath>& spill_store_paths,
167
                                     const std::set<std::string>& broken_paths);
168
169
    // Stop all threads and delete resources.
170
    void destroy();
171
172
    /// Returns the first created exec env instance. In a normal doris, this is
173
    /// the only instance. In test setups with multiple ExecEnv's per process,
174
    /// we return the most recently created instance.
175
715M
    static ExecEnv* GetInstance() {
176
715M
        static ExecEnv s_exec_env;
177
715M
        return &s_exec_env;
178
715M
    }
179
180
    // Requires ExenEnv ready
181
    /*
182
     * Parameters:
183
     * - tablet_id: the id of tablet to get
184
     * - sync_stats: the stats of sync rowset
185
     * - force_use_only_cached: whether only use cached data
186
     * - cache_on_miss: whether cache the tablet meta when missing in cache
187
     */
188
    static Result<BaseTabletSPtr> get_tablet(int64_t tablet_id,
189
                                             SyncRowsetStats* sync_stats = nullptr,
190
                                             bool force_use_only_cached = false,
191
                                             bool cache_on_miss = true);
192
193
    static Status get_tablet_meta(int64_t tablet_id, TabletMetaSharedPtr* tablet_meta,
194
                                  bool force_use_only_cached = false);
195
196
623k
    static bool ready() { return _s_ready.load(std::memory_order_acquire); }
197
994k
    static bool tracking_memory() { return _s_tracking_memory.load(std::memory_order_acquire); }
198
2.00k
    static bool get_is_upgrading() { return _s_upgrading.load(std::memory_order_acquire); }
199
0
    static void set_is_upgrading() { _s_upgrading = true; }
200
    const std::string& token() const;
201
10
    ExternalScanContextMgr* external_scan_context_mgr() { return _external_scan_context_mgr; }
202
6.01M
    VDataStreamMgr* vstream_mgr() { return _vstream_mgr; }
203
1.09M
    ResultBufferMgr* result_mgr() { return _result_mgr; }
204
12
    ResultQueueMgr* result_queue_mgr() { return _result_queue_mgr; }
205
0
    ClientCache<BackendServiceClient>* client_cache() { return _backend_client_cache; }
206
55.0k
    ClientCache<FrontendServiceClient>* frontend_client_cache() { return _frontend_client_cache; }
207
222
    ClientCache<TPaloBrokerServiceClient>* broker_client_cache() { return _broker_client_cache; }
208
209
1.21M
    WorkloadGroupMgr* workload_group_mgr() { return _workload_group_manager; }
210
1.58k
    WorkloadSchedPolicyMgr* workload_sched_policy_mgr() { return _workload_sched_mgr; }
211
291k
    RuntimeQueryStatisticsMgr* runtime_query_statistics_mgr() {
212
291k
        return _runtime_query_statistics_mgr;
213
291k
    }
214
215
    // using template to simplify client cache management
216
    template <typename T>
217
    inline ClientCache<T>* get_client_cache() {
218
        return nullptr;
219
    }
220
221
    // Save all MemTrackerLimiters in use.
222
    // Each group corresponds to several MemTrackerLimiters and has a lock.
223
    // Multiple groups are used to reduce the impact of locks.
224
    std::vector<TrackerLimiterGroup> mem_tracker_limiter_pool;
225
    void init_mem_tracker();
226
9.74M
    std::shared_ptr<MemTrackerLimiter> orphan_mem_tracker() { return _orphan_mem_tracker; }
227
302k
    std::shared_ptr<MemTrackerLimiter> brpc_iobuf_block_memory_tracker() {
228
302k
        return _brpc_iobuf_block_memory_tracker;
229
302k
    }
230
0
    std::shared_ptr<MemTrackerLimiter> segcompaction_mem_tracker() {
231
0
        return _segcompaction_mem_tracker;
232
0
    }
233
306k
    std::shared_ptr<MemTrackerLimiter> stream_load_pipe_tracker() {
234
306k
        return _stream_load_pipe_tracker;
235
306k
    }
236
1.23k
    std::shared_ptr<MemTrackerLimiter> tablets_no_cache_mem_tracker() {
237
1.23k
        return _tablets_no_cache_mem_tracker;
238
1.23k
    }
239
1.23k
    std::shared_ptr<MemTrackerLimiter> rowsets_no_cache_mem_tracker() {
240
1.23k
        return _rowsets_no_cache_mem_tracker;
241
1.23k
    }
242
1.23k
    std::shared_ptr<MemTrackerLimiter> segments_no_cache_mem_tracker() {
243
1.23k
        return _segments_no_cache_mem_tracker;
244
1.23k
    }
245
2.88k
    std::shared_ptr<MemTrackerLimiter> point_query_executor_mem_tracker() {
246
2.88k
        return _point_query_executor_mem_tracker;
247
2.88k
    }
248
1.47k
    std::shared_ptr<MemTrackerLimiter> query_cache_mem_tracker() {
249
1.47k
        return _query_cache_mem_tracker;
250
1.47k
    }
251
454k
    std::shared_ptr<MemTrackerLimiter> block_compression_mem_tracker() {
252
454k
        return _block_compression_mem_tracker;
253
454k
    }
254
9.31k
    std::shared_ptr<MemTrackerLimiter> rowid_storage_reader_tracker() {
255
9.31k
        return _rowid_storage_reader_tracker;
256
9.31k
    }
257
248k
    std::shared_ptr<MemTrackerLimiter> subcolumns_tree_tracker() {
258
248k
        return _subcolumns_tree_tracker;
259
248k
    }
260
52.6k
    std::shared_ptr<MemTrackerLimiter> s3_file_buffer_tracker() { return _s3_file_buffer_tracker; }
261
22.0k
    std::shared_ptr<MemTrackerLimiter> parquet_meta_tracker() { return _parquet_meta_tracker; }
262
263
65.6k
    ThreadPool* send_batch_thread_pool() { return _send_batch_thread_pool.get(); }
264
176
    ThreadPool* buffered_reader_prefetch_thread_pool() {
265
176
        return _buffered_reader_prefetch_thread_pool.get();
266
176
    }
267
0
    ThreadPool* send_table_stats_thread_pool() { return _send_table_stats_thread_pool.get(); }
268
89.3k
    ThreadPool* s3_file_upload_thread_pool() { return _s3_file_upload_thread_pool.get(); }
269
0
    ThreadPool* lazy_release_obj_pool() { return _lazy_release_obj_pool.get(); }
270
    ThreadPool* non_block_close_thread_pool();
271
0
    ThreadPool* s3_file_system_thread_pool() { return _s3_file_system_thread_pool.get(); }
272
0
    ThreadPool* udf_close_workers_pool() { return _udf_close_workers_thread_pool.get(); }
273
852k
    ThreadPool* segment_prefetch_thread_pool() { return _segment_prefetch_thread_pool.get(); }
274
275
    void init_file_cache_factory(std::vector<doris::CachePath>& cache_paths);
276
2.06M
    io::FileCacheFactory* file_cache_factory() { return _file_cache_factory; }
277
7.67k
    UserFunctionCache* user_function_cache() { return _user_function_cache; }
278
2.24M
    FragmentMgr* fragment_mgr() { return _fragment_mgr; }
279
76.4k
    ResultCache* result_cache() { return _result_cache; }
280
555M
    ClusterInfo* cluster_info() { return _cluster_info; }
281
1.76k
    LoadPathMgr* load_path_mgr() { return _load_path_mgr; }
282
8
    BfdParser* bfd_parser() const { return _bfd_parser; }
283
2
    BrokerMgr* broker_mgr() const { return _broker_mgr; }
284
2.80M
    BrpcClientCache<PBackendService_Stub>* brpc_internal_client_cache() const {
285
2.80M
        return _internal_client_cache;
286
2.80M
    }
287
5.51k
    BrpcClientCache<PBackendService_Stub>* brpc_streaming_client_cache() const {
288
5.51k
        return _streaming_client_cache;
289
5.51k
    }
290
0
    BrpcClientCache<PFunctionService_Stub>* brpc_function_client_cache() const {
291
0
        return _function_client_cache;
292
0
    }
293
135k
    LoadChannelMgr* load_channel_mgr() { return _load_channel_mgr; }
294
3.99k
    LoadStreamMgr* load_stream_mgr() { return _load_stream_mgr.get(); }
295
20.3k
    NewLoadStreamMgr* new_load_stream_mgr() { return _new_load_stream_mgr.get(); }
296
0
    SmallFileMgr* small_file_mgr() { return _small_file_mgr; }
297
68.4k
    doris::SpillStreamManager* spill_stream_mgr() { return _spill_stream_mgr; }
298
319
    GroupCommitMgr* group_commit_mgr() { return _group_commit_mgr; }
299
1.24k
    CdcClientMgr* cdc_client_mgr() { return _cdc_client_mgr; }
300
301
33
    const std::vector<StorePath>& store_paths() const { return _store_paths; }
302
303
7.07k
    StreamLoadExecutor* stream_load_executor() { return _stream_load_executor.get(); }
304
9.54k
    RoutineLoadTaskExecutor* routine_load_task_executor() { return _routine_load_task_executor; }
305
1.74k
    HeartbeatFlags* heartbeat_flags() { return _heartbeat_flags; }
306
146k
    FileMetaCache* file_meta_cache() { return _file_meta_cache; }
307
474k
    MemTableMemoryLimiter* memtable_memory_limiter() { return _memtable_memory_limiter.get(); }
308
2.36k
    WalManager* wal_mgr() { return _wal_manager.get(); }
309
2.94M
    DNSCache* dns_cache() { return _dns_cache; }
310
7
    WriteCooldownMetaExecutors* write_cooldown_meta_executors() {
311
7
        return _write_cooldown_meta_executors.get();
312
7
    }
313
314
1
    kerberos::KerberosTicketMgr* kerberos_ticket_mgr() { return _kerberos_ticket_mgr; }
315
54.0k
    io::HdfsMgr* hdfs_mgr() { return _hdfs_mgr; }
316
0
    io::PackedFileManager* packed_file_manager() { return _packed_file_manager; }
317
2.25k
    IndexPolicyMgr* index_policy_mgr() { return _index_policy_mgr; }
318
0
    S3RateLimiterHolder* warmup_download_rate_limiter() { return _warmup_download_rate_limiter; }
319
0
    cloud::HostLevelMSRpcRateLimiters* host_level_ms_rpc_rate_limiters() {
320
0
        return _host_level_ms_rpc_rate_limiters.get();
321
0
    }
322
0
    cloud::TableRpcQpsRegistry* table_rpc_qps_registry() { return _table_rpc_qps_registry.get(); }
323
1
    cloud::TableRpcThrottler* table_rpc_throttler() { return _table_rpc_throttler.get(); }
324
0
    cloud::MSBackpressureHandler* ms_backpressure_handler() {
325
0
        return _ms_backpressure_handler.get();
326
0
    }
327
328
#ifdef BE_TEST
329
    void set_tmp_file_dir(std::unique_ptr<segment_v2::TmpFileDirs> tmp_file_dirs) {
330
        this->_tmp_file_dirs = std::move(tmp_file_dirs);
331
    }
332
    void set_ready() { this->_s_ready = true; }
333
    void set_not_ready() { this->_s_ready = false; }
334
    void set_memtable_memory_limiter(MemTableMemoryLimiter* limiter) {
335
        _memtable_memory_limiter.reset(limiter);
336
    }
337
    void set_cluster_info(ClusterInfo* cluster_info) { this->_cluster_info = cluster_info; }
338
    void set_new_load_stream_mgr(std::unique_ptr<NewLoadStreamMgr>&& new_load_stream_mgr);
339
    void clear_new_load_stream_mgr();
340
    void set_stream_load_executor(std::unique_ptr<StreamLoadExecutor>&& stream_load_executor);
341
    void clear_stream_load_executor();
342
343
    void set_storage_engine(std::unique_ptr<BaseStorageEngine>&& engine);
344
    void set_inverted_index_searcher_cache(
345
            segment_v2::InvertedIndexSearcherCache* inverted_index_searcher_cache);
346
    void set_inverted_index_query_cache(
347
            segment_v2::InvertedIndexQueryCache* inverted_index_query_cache) {
348
        _inverted_index_query_cache = inverted_index_query_cache;
349
    }
350
    void set_cache_manager(CacheManager* cm) { this->_cache_manager = cm; }
351
    void set_process_profile(ProcessProfile* pp) { this->_process_profile = pp; }
352
    void set_tablet_schema_cache(TabletSchemaCache* c) { this->_tablet_schema_cache = c; }
353
    void set_delete_bitmap_agg_cache(DeleteBitmapAggCache* c) { _delete_bitmap_agg_cache = c; }
354
    void set_tablet_column_object_pool(TabletColumnObjectPool* c) {
355
        this->_tablet_column_object_pool = c;
356
    }
357
    void set_storage_page_cache(StoragePageCache* c) { this->_storage_page_cache = c; }
358
    void set_segment_loader(SegmentLoader* sl) { this->_segment_loader = sl; }
359
    void set_routine_load_task_executor(RoutineLoadTaskExecutor* r) {
360
        this->_routine_load_task_executor = r;
361
    }
362
    void set_wal_mgr(std::unique_ptr<WalManager>&& wm);
363
    void clear_wal_mgr();
364
365
    void set_write_cooldown_meta_executors();
366
    static void set_tracking_memory(bool tracking_memory) {
367
        _s_tracking_memory.store(tracking_memory, std::memory_order_release);
368
    }
369
    void set_orc_memory_pool(orc::MemoryPool* pool) { _orc_memory_pool = pool; }
370
    void set_non_block_close_thread_pool(std::unique_ptr<ThreadPool>&& pool) {
371
        _non_block_close_thread_pool = std::move(pool);
372
    }
373
    void set_s3_file_upload_thread_pool(std::unique_ptr<ThreadPool>&& pool) {
374
        _s3_file_upload_thread_pool = std::move(pool);
375
    }
376
    void set_file_cache_factory(io::FileCacheFactory* factory) { _file_cache_factory = factory; }
377
    void set_file_cache_open_fd_cache(std::unique_ptr<io::FDCache>&& fd_cache) {
378
        _file_cache_open_fd_cache = std::move(fd_cache);
379
    }
380
#endif
381
5.51k
    LoadStreamMapPool* load_stream_map_pool() { return _load_stream_map_pool.get(); }
382
383
5.50k
    DeltaWriterV2Pool* delta_writer_v2_pool() { return _delta_writer_v2_pool.get(); }
384
385
    void wait_for_all_tasks_done();
386
387
    void update_frontends(const std::vector<TFrontendInfo>& new_infos);
388
    std::vector<TFrontendInfo> get_frontends();
389
    std::map<TNetworkAddress, FrontendInfo> get_running_frontends();
390
391
3.52M
    TabletSchemaCache* get_tablet_schema_cache() { return _tablet_schema_cache; }
392
5.49M
    TabletColumnObjectPool* get_tablet_column_object_pool() { return _tablet_column_object_pool; }
393
2.95M
    SchemaCache* schema_cache() { return _schema_cache; }
394
9.72M
    StoragePageCache* get_storage_page_cache() { return _storage_page_cache; }
395
2.51M
    SegmentLoader* segment_loader() { return _segment_loader; }
396
358
    LookupConnectionCache* get_lookup_connection_cache() { return _lookup_connection_cache; }
397
321
    RowCache* get_row_cache() { return _row_cache; }
398
2.68k
    CacheManager* get_cache_manager() { return _cache_manager; }
399
12.2k
    IdManager* get_id_manager() { return _id_manager; }
400
2.48k
    ProcessProfile* get_process_profile() { return _process_profile; }
401
0
    HeapProfiler* get_heap_profiler() { return _heap_profiler; }
402
39.8k
    segment_v2::InvertedIndexSearcherCache* get_inverted_index_searcher_cache() {
403
39.8k
        return _inverted_index_searcher_cache;
404
39.8k
    }
405
24.5k
    segment_v2::InvertedIndexQueryCache* get_inverted_index_query_cache() {
406
24.5k
        return _inverted_index_query_cache;
407
24.5k
    }
408
3.34M
    segment_v2::ConditionCache* get_condition_cache() { return _condition_cache; }
409
35.5M
    segment_v2::EncodingInfoResolver* get_encoding_info_resolver() {
410
35.5M
        return _encoding_info_resolver;
411
35.5M
    }
412
730
    QueryCache* get_query_cache() { return _query_cache; }
413
414
47.2k
    RuntimeFilterTimerQueue* runtime_filter_timer_queue() { return _runtime_filter_timer_queue; }
415
416
4.04k
    DictionaryFactory* dict_factory() { return _dict_factory; }
417
418
8.41M
    PipelineTracerContext* pipeline_tracer_context() { return _pipeline_tracer_ctx.get(); }
419
420
6.63k
    segment_v2::TmpFileDirs* get_tmp_file_dirs() { return _tmp_file_dirs.get(); }
421
23.3M
    io::FDCache* file_cache_open_fd_cache() const { return _file_cache_open_fd_cache.get(); }
422
423
39.0k
    orc::MemoryPool* orc_memory_pool() { return _orc_memory_pool; }
424
7.70k
    arrow::MemoryPool* arrow_memory_pool() { return _arrow_memory_pool; }
425
426
    bool check_auth_token(const std::string& auth_token);
427
10
    void set_stream_mgr(VDataStreamMgr* vstream_mgr) { _vstream_mgr = vstream_mgr; }
428
    void clear_stream_mgr();
429
430
11.7M
    DeleteBitmapAggCache* delete_bitmap_agg_cache() { return _delete_bitmap_agg_cache; }
431
    Status init_mem_env();
432
433
private:
434
    ExecEnv();
435
436
    [[nodiscard]] Status _init(const std::vector<StorePath>& store_paths,
437
                               const std::vector<StorePath>& spill_store_paths,
438
                               const std::set<std::string>& broken_paths);
439
    void _destroy();
440
441
    Status _check_deploy_mode();
442
443
    Status _create_internal_workload_group();
444
    void _init_runtime_filter_timer_queue();
445
446
    inline static std::atomic_bool _s_ready {false};
447
    inline static std::atomic_bool _s_tracking_memory {false};
448
    std::vector<StorePath> _store_paths;
449
    std::vector<StorePath> _spill_store_paths;
450
    inline static std::atomic_bool _s_upgrading {false};
451
452
    io::FileCacheFactory* _file_cache_factory = nullptr;
453
    UserFunctionCache* _user_function_cache = nullptr;
454
    // Leave protected so that subclasses can override
455
    ExternalScanContextMgr* _external_scan_context_mgr = nullptr;
456
    VDataStreamMgr* _vstream_mgr = nullptr;
457
    ResultBufferMgr* _result_mgr = nullptr;
458
    ResultQueueMgr* _result_queue_mgr = nullptr;
459
    ClientCache<BackendServiceClient>* _backend_client_cache = nullptr;
460
    ClientCache<FrontendServiceClient>* _frontend_client_cache = nullptr;
461
    ClientCache<TPaloBrokerServiceClient>* _broker_client_cache = nullptr;
462
463
    // The default tracker consumed by mem hook. If the thread does not attach other trackers,
464
    // by default all consumption will be passed to the process tracker through the orphan tracker.
465
    // In real time, `consumption of all limiter trackers` + `orphan tracker consumption` = `process tracker consumption`.
466
    // Ideally, all threads are expected to attach to the specified tracker, so that "all memory has its own ownership",
467
    // and the consumption of the orphan mem tracker is close to 0, but greater than 0.
468
    std::shared_ptr<MemTrackerLimiter> _orphan_mem_tracker;
469
    std::shared_ptr<MemTrackerLimiter> _brpc_iobuf_block_memory_tracker;
470
    // Count the memory consumption of segment compaction tasks.
471
    std::shared_ptr<MemTrackerLimiter> _segcompaction_mem_tracker;
472
    std::shared_ptr<MemTrackerLimiter> _stream_load_pipe_tracker;
473
474
    std::shared_ptr<MemTrackerLimiter> _tablets_no_cache_mem_tracker;
475
    std::shared_ptr<MemTrackerLimiter> _rowsets_no_cache_mem_tracker;
476
    std::shared_ptr<MemTrackerLimiter> _segments_no_cache_mem_tracker;
477
478
    // Tracking memory may be shared between multiple queries.
479
    std::shared_ptr<MemTrackerLimiter> _point_query_executor_mem_tracker;
480
    std::shared_ptr<MemTrackerLimiter> _block_compression_mem_tracker;
481
    std::shared_ptr<MemTrackerLimiter> _query_cache_mem_tracker;
482
483
    // TODO, looking forward to more accurate tracking.
484
    std::shared_ptr<MemTrackerLimiter> _rowid_storage_reader_tracker;
485
    std::shared_ptr<MemTrackerLimiter> _subcolumns_tree_tracker;
486
    std::shared_ptr<MemTrackerLimiter> _s3_file_buffer_tracker;
487
488
    // Tracking memory consumption of parquet meta
489
    std::shared_ptr<MemTrackerLimiter> _parquet_meta_tracker;
490
491
    std::unique_ptr<ThreadPool> _send_batch_thread_pool;
492
    // Threadpool used to prefetch remote file for buffered reader
493
    std::unique_ptr<ThreadPool> _buffered_reader_prefetch_thread_pool;
494
    // Threadpool used to send TableStats to FE
495
    std::unique_ptr<ThreadPool> _send_table_stats_thread_pool;
496
    // Threadpool used to upload local file to s3
497
    std::unique_ptr<ThreadPool> _s3_file_upload_thread_pool;
498
    // Pool used by join node to build hash table
499
    // Pool to use a new thread to release object
500
    std::unique_ptr<ThreadPool> _lazy_release_obj_pool;
501
    std::unique_ptr<ThreadPool> _non_block_close_thread_pool;
502
    std::unique_ptr<ThreadPool> _s3_file_system_thread_pool;
503
    // for java-udf to close
504
    std::unique_ptr<ThreadPool> _udf_close_workers_thread_pool;
505
    // Threadpool used to prefetch segment file cache blocks
506
    std::unique_ptr<ThreadPool> _segment_prefetch_thread_pool;
507
508
    FragmentMgr* _fragment_mgr = nullptr;
509
    WorkloadGroupMgr* _workload_group_manager = nullptr;
510
511
    ResultCache* _result_cache = nullptr;
512
    ClusterInfo* _cluster_info = nullptr;
513
    LoadPathMgr* _load_path_mgr = nullptr;
514
515
    BfdParser* _bfd_parser = nullptr;
516
    BrokerMgr* _broker_mgr = nullptr;
517
    LoadChannelMgr* _load_channel_mgr = nullptr;
518
    std::unique_ptr<LoadStreamMgr> _load_stream_mgr;
519
    std::unique_ptr<NewLoadStreamMgr> _new_load_stream_mgr;
520
    BrpcClientCache<PBackendService_Stub>* _internal_client_cache = nullptr;
521
    BrpcClientCache<PBackendService_Stub>* _streaming_client_cache = nullptr;
522
    BrpcClientCache<PFunctionService_Stub>* _function_client_cache = nullptr;
523
524
    std::unique_ptr<StreamLoadExecutor> _stream_load_executor;
525
    RoutineLoadTaskExecutor* _routine_load_task_executor = nullptr;
526
    StreamLoadRecorderManager* _stream_load_recorder_manager = nullptr;
527
    SmallFileMgr* _small_file_mgr = nullptr;
528
    HeartbeatFlags* _heartbeat_flags = nullptr;
529
530
    // To save meta info of external file, such as parquet footer.
531
    FileMetaCache* _file_meta_cache = nullptr;
532
    std::unique_ptr<MemTableMemoryLimiter> _memtable_memory_limiter;
533
    std::unique_ptr<LoadStreamMapPool> _load_stream_map_pool;
534
    std::unique_ptr<DeltaWriterV2Pool> _delta_writer_v2_pool;
535
    std::unique_ptr<WalManager> _wal_manager;
536
    DNSCache* _dns_cache = nullptr;
537
    std::unique_ptr<WriteCooldownMetaExecutors> _write_cooldown_meta_executors;
538
539
    std::mutex _frontends_lock;
540
    // ip:brpc_port -> frontend_indo
541
    std::map<TNetworkAddress, FrontendInfo> _frontends;
542
    GroupCommitMgr* _group_commit_mgr = nullptr;
543
    CdcClientMgr* _cdc_client_mgr = nullptr;
544
545
    // Maybe we should use unique_ptr, but it need complete type, which means we need
546
    // to include many headers, and for some cpp file that do not need class like TabletSchemaCache,
547
    // these redundancy header could introduce potential bug, at least, more header means slow compile.
548
    // So we choose to use raw pointer, please remember to delete these pointer in deconstructor.
549
    TabletSchemaCache* _tablet_schema_cache = nullptr;
550
    TabletColumnObjectPool* _tablet_column_object_pool = nullptr;
551
    std::unique_ptr<BaseStorageEngine> _storage_engine;
552
    SchemaCache* _schema_cache = nullptr;
553
    StoragePageCache* _storage_page_cache = nullptr;
554
    SegmentLoader* _segment_loader = nullptr;
555
    LookupConnectionCache* _lookup_connection_cache = nullptr;
556
    RowCache* _row_cache = nullptr;
557
    CacheManager* _cache_manager = nullptr;
558
    IdManager* _id_manager = nullptr;
559
    ProcessProfile* _process_profile = nullptr;
560
    HeapProfiler* _heap_profiler = nullptr;
561
    segment_v2::InvertedIndexSearcherCache* _inverted_index_searcher_cache = nullptr;
562
    segment_v2::InvertedIndexQueryCache* _inverted_index_query_cache = nullptr;
563
    segment_v2::ConditionCache* _condition_cache = nullptr;
564
    segment_v2::EncodingInfoResolver* _encoding_info_resolver = nullptr;
565
    QueryCache* _query_cache = nullptr;
566
    std::unique_ptr<io::FDCache> _file_cache_open_fd_cache;
567
    DeleteBitmapAggCache* _delete_bitmap_agg_cache {nullptr};
568
569
    RuntimeFilterTimerQueue* _runtime_filter_timer_queue = nullptr;
570
    DictionaryFactory* _dict_factory = nullptr;
571
572
    WorkloadSchedPolicyMgr* _workload_sched_mgr = nullptr;
573
    IndexPolicyMgr* _index_policy_mgr = nullptr;
574
575
    RuntimeQueryStatisticsMgr* _runtime_query_statistics_mgr = nullptr;
576
577
    std::unique_ptr<PipelineTracerContext> _pipeline_tracer_ctx;
578
    std::unique_ptr<segment_v2::TmpFileDirs> _tmp_file_dirs;
579
    doris::SpillStreamManager* _spill_stream_mgr = nullptr;
580
581
    orc::MemoryPool* _orc_memory_pool = nullptr;
582
    arrow::MemoryPool* _arrow_memory_pool = nullptr;
583
584
    kerberos::KerberosTicketMgr* _kerberos_ticket_mgr = nullptr;
585
    io::HdfsMgr* _hdfs_mgr = nullptr;
586
    io::PackedFileManager* _packed_file_manager = nullptr;
587
    S3RateLimiterHolder* _warmup_download_rate_limiter = nullptr;
588
589
    std::unique_ptr<cloud::HostLevelMSRpcRateLimiters> _host_level_ms_rpc_rate_limiters;
590
    std::unique_ptr<cloud::TableRpcQpsRegistry> _table_rpc_qps_registry;
591
    std::unique_ptr<cloud::TableRpcThrottler> _table_rpc_throttler;
592
    std::unique_ptr<cloud::MSBackpressureHandler> _ms_backpressure_handler;
593
};
594
595
template <>
596
0
inline ClientCache<BackendServiceClient>* ExecEnv::get_client_cache<BackendServiceClient>() {
597
0
    return _backend_client_cache;
598
0
}
599
template <>
600
33.7k
inline ClientCache<FrontendServiceClient>* ExecEnv::get_client_cache<FrontendServiceClient>() {
601
33.7k
    return _frontend_client_cache;
602
33.7k
}
603
template <>
604
inline ClientCache<TPaloBrokerServiceClient>*
605
0
ExecEnv::get_client_cache<TPaloBrokerServiceClient>() {
606
0
    return _broker_client_cache;
607
0
}
608
609
0
inline segment_v2::InvertedIndexQueryCache* GetInvertedIndexQueryCache() {
610
0
    return ExecEnv::GetInstance()->get_inverted_index_query_cache();
611
0
}
612
613
} // namespace doris