Coverage Report

Created: 2025-07-27 01:30

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