Coverage Report

Created: 2026-04-01 07:28

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