Coverage Report

Created: 2026-02-28 19:26

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