Coverage Report

Created: 2026-05-08 13:05

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