Coverage Report

Created: 2025-05-05 03:34

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