Coverage Report

Created: 2026-05-11 06:06

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