Coverage Report

Created: 2025-10-23 12:18

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