Coverage Report

Created: 2024-11-21 16:04

/root/doris/be/src/common/config.cpp
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
#include <fmt/core.h>
19
#include <stdint.h>
20
21
#include <algorithm>
22
#include <cctype>
23
// IWYU pragma: no_include <bthread/errno.h>
24
#include <lz4/lz4hc.h>
25
26
#include <cerrno> // IWYU pragma: keep
27
#include <cstdlib>
28
#include <cstring>
29
#include <fstream> // IWYU pragma: keep
30
#include <functional>
31
#include <iostream>
32
#include <map>
33
#include <memory>
34
#include <mutex>
35
#include <random>
36
#include <string>
37
#include <utility>
38
#include <vector>
39
40
#include "common/config.h"
41
#include "common/logging.h"
42
#include "common/status.h"
43
#include "config.h"
44
#include "io/fs/file_writer.h"
45
#include "io/fs/local_file_system.h"
46
#include "util/cpu_info.h"
47
48
namespace doris::config {
49
50
// Dir of custom config file
51
DEFINE_String(custom_config_dir, "${DORIS_HOME}/conf");
52
53
// Dir of jdbc drivers
54
DEFINE_String(jdbc_drivers_dir, "${DORIS_HOME}/jdbc_drivers");
55
56
// cluster id
57
DEFINE_Int32(cluster_id, "-1");
58
// port on which BackendService is exported
59
DEFINE_Int32(be_port, "9060");
60
61
// port for brpc
62
DEFINE_Int32(brpc_port, "8060");
63
64
DEFINE_Int32(arrow_flight_sql_port, "-1");
65
66
// If the external client cannot directly access priority_networks, set public_host to be accessible
67
// to external client.
68
// There are usually two usage scenarios:
69
// 1. in production environment, it is often inconvenient to expose Doris BE nodes to the external network.
70
// However, a reverse proxy (such as Nginx) can be added to all Doris BE nodes, and the external client will be
71
// randomly routed to a Doris BE node when connecting to Nginx. set public_host to the host of Nginx.
72
// 2. if priority_networks is an internal network IP, and BE node has its own independent external IP,
73
// but Doris currently does not support modifying priority_networks, setting public_host to the real external IP.
74
DEFINE_mString(public_host, "");
75
76
// If the BE node is connected to the external network through a reverse proxy like Nginx
77
// and need to use Arrow Flight SQL, should add a server in Nginx to reverse proxy
78
// `Nginx:arrow_flight_sql_proxy_port` to `BE_priority_networks:arrow_flight_sql_port`. For example:
79
// upstream arrowflight {
80
//    server 10.16.10.8:8069;
81
//    server 10.16.10.8:8068;
82
//}
83
// server {
84
//    listen 8167 http2;
85
//    listen [::]:8167 http2;
86
//    server_name doris.arrowflight.com;
87
// }
88
DEFINE_Int32(arrow_flight_sql_proxy_port, "-1");
89
90
// the number of bthreads for brpc, the default value is set to -1,
91
// which means the number of bthreads is #cpu-cores
92
DEFINE_Int32(brpc_num_threads, "256");
93
// the time of brpc server keep idle connection, setting this value too small may cause rpc between backends to fail,
94
// the default value is set to -1, which means never close idle connection.
95
DEFINE_Int32(brpc_idle_timeout_sec, "-1");
96
97
// Declare a selection strategy for those servers have many ips.
98
// Note that there should at most one ip match this list.
99
// this is a list in semicolon-delimited format, in CIDR notation, e.g. 10.10.10.0/24
100
// If no ip match this rule, will choose one randomly.
101
DEFINE_String(priority_networks, "");
102
103
// memory mode
104
// performance or compact
105
DEFINE_String(memory_mode, "moderate");
106
107
DEFINE_mBool(enable_use_cgroup_memory_info, "true");
108
109
// process memory limit specified as number of bytes
110
// ('<int>[bB]?'), megabytes ('<float>[mM]'), gigabytes ('<float>[gG]'),
111
// or percentage of the physical memory ('<int>%').
112
// defaults to bytes if no unit is given"
113
// must larger than 0. and if larger than physical memory size,
114
// it will be set to physical memory size.
115
DEFINE_String(mem_limit, "90%");
116
117
// Soft memory limit as a fraction of hard memory limit.
118
DEFINE_Double(soft_mem_limit_frac, "0.9");
119
120
// Schema change memory limit as a fraction of soft memory limit.
121
DEFINE_Double(schema_change_mem_limit_frac, "0.6");
122
123
// Many modern allocators (for example, tcmalloc) do not do a mremap for
124
// realloc, even in case of large enough chunks of memory. Although this allows
125
// you to increase performance and reduce memory consumption during realloc.
126
// To fix this, we do mremap manually if the chunk of memory is large enough.
127
//
128
// The threshold (128 MB, 128 * (1ULL << 20)) is chosen quite large, since changing the address
129
// space is very slow, especially in the case of a large number of threads. We
130
// expect that the set of operations mmap/something to do/mremap can only be
131
// performed about 1000 times per second.
132
//
133
// P.S. This is also required, because tcmalloc can not allocate a chunk of
134
// memory greater than 16 GB.
135
DEFINE_mInt64(mmap_threshold, "134217728"); // bytes
136
137
// When hash table capacity is greater than 2^double_grow_degree(default 2G), grow when 75% of the capacity is satisfied.
138
// Increase can reduce the number of hash table resize, but may waste more memory.
139
DEFINE_mInt32(hash_table_double_grow_degree, "31");
140
141
DEFINE_mInt32(max_fill_rate, "2");
142
143
DEFINE_mInt32(double_resize_threshold, "23");
144
145
DEFINE_Int64(max_sys_mem_available_low_water_mark_bytes, "6871947673");
146
147
DEFINE_Int64(memtable_limiter_reserved_memory_bytes, "838860800");
148
149
// The size of the memory that gc wants to release each time, as a percentage of the mem limit.
150
DEFINE_mString(process_minor_gc_size, "5%");
151
DEFINE_mString(process_full_gc_size, "10%");
152
153
// If true, when the process does not exceed the soft mem limit, the query memory will not be limited;
154
// when the process memory exceeds the soft mem limit, the query with the largest ratio between the currently
155
// used memory and the exec_mem_limit will be canceled.
156
// If false, cancel query when the memory used exceeds exec_mem_limit, same as before.
157
DEFINE_mBool(enable_query_memory_overcommit, "true");
158
159
DEFINE_mBool(disable_memory_gc, "false");
160
161
DEFINE_mInt64(stacktrace_in_alloc_large_memory_bytes, "2147483648");
162
163
DEFINE_mInt64(crash_in_alloc_large_memory_bytes, "-1");
164
165
// If memory tracker value is inaccurate, BE will crash. usually used in test environments, default value is false.
166
DEFINE_mBool(crash_in_memory_tracker_inaccurate, "false");
167
168
// default is true. if any memory tracking in Orphan mem tracker will report error.
169
// !! not modify the default value of this conf!! otherwise memory errors cannot be detected in time.
170
// allocator free memory not need to check, because when the thread memory tracker label is Orphan,
171
// use the tracker saved in Allocator.
172
DEFINE_mBool(enable_memory_orphan_check, "true");
173
174
// The maximum time a thread waits for full GC. Currently only query will wait for full gc.
175
DEFINE_mInt32(thread_wait_gc_max_milliseconds, "1000");
176
177
DEFINE_mInt64(pre_serialize_keys_limit_bytes, "16777216");
178
179
// the port heartbeat service used
180
DEFINE_Int32(heartbeat_service_port, "9050");
181
// the count of heart beat service
182
DEFINE_Int32(heartbeat_service_thread_count, "1");
183
// the count of thread to create table
184
DEFINE_Int32(create_tablet_worker_count, "3");
185
// the count of thread to drop table
186
DEFINE_Int32(drop_tablet_worker_count, "3");
187
// the count of thread to batch load
188
DEFINE_Int32(push_worker_count_normal_priority, "3");
189
// the count of thread to high priority batch load
190
DEFINE_Int32(push_worker_count_high_priority, "3");
191
// the count of thread to publish version
192
DEFINE_Int32(publish_version_worker_count, "8");
193
// the count of tablet thread to publish version
194
DEFINE_Int32(tablet_publish_txn_max_thread, "32");
195
// the timeout of EnginPublishVersionTask
196
DEFINE_Int32(publish_version_task_timeout_s, "8");
197
// the count of thread to calc delete bitmap
198
DEFINE_Int32(calc_delete_bitmap_max_thread, "32");
199
// the count of thread to clear transaction task
200
DEFINE_Int32(clear_transaction_task_worker_count, "1");
201
// the count of thread to delete
202
DEFINE_Int32(delete_worker_count, "3");
203
// the count of thread to alter table
204
DEFINE_Int32(alter_tablet_worker_count, "3");
205
// the count of thread to alter index
206
DEFINE_Int32(alter_index_worker_count, "3");
207
// the count of thread to clone
208
DEFINE_Int32(clone_worker_count, "3");
209
// the count of thread to clone
210
DEFINE_Int32(storage_medium_migrate_count, "1");
211
// the count of thread to check consistency
212
DEFINE_Int32(check_consistency_worker_count, "1");
213
// the count of thread to upload
214
DEFINE_Int32(upload_worker_count, "1");
215
// the count of thread to download
216
DEFINE_Int32(download_worker_count, "1");
217
// the count of thread to make snapshot
218
DEFINE_Int32(make_snapshot_worker_count, "5");
219
// the count of thread to release snapshot
220
DEFINE_Int32(release_snapshot_worker_count, "5");
221
// report random wait a little time to avoid FE receiving multiple be reports at the same time.
222
// do not set it to false for production environment
223
DEFINE_mBool(report_random_wait, "true");
224
// the interval time(seconds) for agent report tasks signature to FE
225
DEFINE_mInt32(report_task_interval_seconds, "10");
226
// the interval time(seconds) for refresh storage policy from FE
227
DEFINE_mInt32(storage_refresh_storage_policy_task_interval_seconds, "5");
228
// the interval time(seconds) for agent report disk state to FE
229
DEFINE_mInt32(report_disk_state_interval_seconds, "60");
230
// the interval time(seconds) for agent report olap table to FE
231
DEFINE_mInt32(report_tablet_interval_seconds, "60");
232
// the max download speed(KB/s)
233
DEFINE_mInt32(max_download_speed_kbps, "50000");
234
// download low speed limit(KB/s)
235
DEFINE_mInt32(download_low_speed_limit_kbps, "50");
236
// download low speed time(seconds)
237
DEFINE_mInt32(download_low_speed_time, "300");
238
239
DEFINE_String(sys_log_dir, "");
240
DEFINE_String(user_function_dir, "${DORIS_HOME}/lib/udf");
241
// INFO, WARNING, ERROR, FATAL
242
DEFINE_mString(sys_log_level, "INFO");
243
// TIME-DAY, TIME-HOUR, SIZE-MB-nnn
244
DEFINE_String(sys_log_roll_mode, "SIZE-MB-1024");
245
// log roll num
246
DEFINE_Int32(sys_log_roll_num, "10");
247
// verbose log
248
DEFINE_Strings(sys_log_verbose_modules, "");
249
// verbose log level
250
DEFINE_Int32(sys_log_verbose_level, "10");
251
// verbose log FLAGS_v
252
DEFINE_Int32(sys_log_verbose_flags_v, "-1");
253
// log buffer level
254
DEFINE_String(log_buffer_level, "");
255
// log enable custom date time format
256
DEFINE_Bool(sys_log_enable_custom_date_time_format, "false");
257
// log custom date time format (https://en.cppreference.com/w/cpp/io/manip/put_time)
258
DEFINE_String(sys_log_custom_date_time_format, "%Y-%m-%d %H:%M:%S");
259
// log custom date time milliseconds format (fmt::format)
260
DEFINE_String(sys_log_custom_date_time_ms_format, ",{:03d}");
261
262
// number of threads available to serve backend execution requests
263
DEFINE_Int32(be_service_threads, "64");
264
265
// interval between profile reports; in seconds
266
DEFINE_mInt32(status_report_interval, "5");
267
// The pipeline task has a high concurrency, therefore reducing its report frequency
268
DEFINE_mInt32(pipeline_status_report_interval, "10");
269
// if true, each disk will have a separate thread pool for scanner
270
DEFINE_Bool(doris_enable_scanner_thread_pool_per_disk, "true");
271
// the timeout of a work thread to wait the blocking priority queue to get a task
272
DEFINE_mInt64(doris_blocking_priority_queue_wait_timeout_ms, "500");
273
// number of scanner thread pool size for olap table
274
// and the min thread num of remote scanner thread pool
275
DEFINE_Int32(doris_scanner_thread_pool_thread_num, "-1");
276
DEFINE_Validator(doris_scanner_thread_pool_thread_num, [](const int config) -> bool {
277
    if (config == -1) {
278
        CpuInfo::init();
279
        doris_scanner_thread_pool_thread_num = std::max(48, CpuInfo::num_cores() * 2);
280
    }
281
    return true;
282
});
283
DEFINE_Int32(doris_scanner_min_thread_pool_thread_num, "8");
284
DEFINE_Int32(remote_split_source_batch_size, "10240");
285
DEFINE_Int32(doris_max_remote_scanner_thread_pool_thread_num, "-1");
286
// number of olap scanner thread pool queue size
287
DEFINE_Int32(doris_scanner_thread_pool_queue_size, "102400");
288
// default thrift client connect timeout(in seconds)
289
DEFINE_mInt32(thrift_connect_timeout_seconds, "3");
290
DEFINE_mInt32(fetch_rpc_timeout_seconds, "30");
291
292
// default thrift client retry interval (in milliseconds)
293
DEFINE_mInt64(thrift_client_retry_interval_ms, "1000");
294
// max message size of thrift request
295
// default: 100 * 1024 * 1024
296
DEFINE_mInt64(thrift_max_message_size, "104857600");
297
// max row count number for single scan range, used in segmentv1
298
DEFINE_mInt32(doris_scan_range_row_count, "524288");
299
// max bytes number for single scan range, used in segmentv2
300
DEFINE_mInt32(doris_scan_range_max_mb, "1024");
301
// max bytes number for single scan block, used in segmentv2
302
DEFINE_mInt32(doris_scan_block_max_mb, "67108864");
303
// size of scanner queue between scanner thread and compute thread
304
DEFINE_mInt32(doris_scanner_queue_size, "1024");
305
// single read execute fragment row number
306
DEFINE_mInt32(doris_scanner_row_num, "16384");
307
// single read execute fragment row bytes
308
DEFINE_mInt32(doris_scanner_row_bytes, "10485760");
309
// single read execute fragment max run time millseconds
310
DEFINE_mInt32(doris_scanner_max_run_time_ms, "1000");
311
DEFINE_mInt32(min_bytes_in_scanner_queue, "67108864");
312
// number of max scan keys
313
DEFINE_mInt32(doris_max_scan_key_num, "48");
314
// the max number of push down values of a single column.
315
// if exceed, no conditions will be pushed down for that column.
316
DEFINE_mInt32(max_pushdown_conditions_per_column, "1024");
317
// (Advanced) Maximum size of per-query receive-side buffer
318
DEFINE_mInt32(exchg_node_buffer_size_bytes, "20485760");
319
DEFINE_mInt32(exchg_buffer_queue_capacity_factor, "64");
320
321
DEFINE_mInt64(column_dictionary_key_ratio_threshold, "0");
322
DEFINE_mInt64(column_dictionary_key_size_threshold, "0");
323
// memory_limitation_per_thread_for_schema_change_bytes unit bytes
324
DEFINE_mInt64(memory_limitation_per_thread_for_schema_change_bytes, "2147483648");
325
DEFINE_mInt64(memory_limitation_per_thread_for_storage_migration_bytes, "100000000");
326
327
DEFINE_mInt32(cache_prune_interval_sec, "10");
328
DEFINE_mInt32(cache_periodic_prune_stale_sweep_sec, "300");
329
// the clean interval of tablet lookup cache
330
DEFINE_mInt32(tablet_lookup_cache_stale_sweep_time_sec, "30");
331
DEFINE_mInt32(point_query_row_cache_stale_sweep_time_sec, "300");
332
DEFINE_mInt32(disk_stat_monitor_interval, "5");
333
DEFINE_mInt32(unused_rowset_monitor_interval, "30");
334
DEFINE_String(storage_root_path, "${DORIS_HOME}/storage");
335
DEFINE_mString(broken_storage_path, "");
336
337
// Config is used to check incompatible old format hdr_ format
338
// whether doris uses strict way. When config is true, process will log fatal
339
// and exit. When config is false, process will only log warning.
340
DEFINE_Bool(storage_strict_check_incompatible_old_format, "true");
341
342
// BE process will exit if the percentage of error disk reach this value.
343
DEFINE_mInt32(max_percentage_of_error_disk, "100");
344
DEFINE_mInt32(default_num_rows_per_column_file_block, "1024");
345
// pending data policy
346
DEFINE_mInt32(pending_data_expire_time_sec, "1800");
347
// inc_rowset snapshot rs sweep time interval
348
DEFINE_mInt32(tablet_rowset_stale_sweep_time_sec, "300");
349
// tablet stale rowset sweep by threshold size
350
DEFINE_Bool(tablet_rowset_stale_sweep_by_size, "false");
351
DEFINE_mInt32(tablet_rowset_stale_sweep_threshold_size, "100");
352
// garbage sweep policy
353
DEFINE_Int32(max_garbage_sweep_interval, "3600");
354
DEFINE_Int32(min_garbage_sweep_interval, "180");
355
DEFINE_mInt32(garbage_sweep_batch_size, "100");
356
DEFINE_mInt32(snapshot_expire_time_sec, "172800");
357
// It is only a recommended value. When the disk space is insufficient,
358
// the file storage period under trash dose not have to comply with this parameter.
359
DEFINE_mInt32(trash_file_expire_time_sec, "86400");
360
// minimum file descriptor number
361
// modify them upon necessity
362
DEFINE_Int32(min_file_descriptor_number, "60000");
363
DEFINE_mBool(disable_segment_cache, "false");
364
DEFINE_String(row_cache_mem_limit, "20%");
365
366
// Cache for storage page size
367
DEFINE_String(storage_page_cache_limit, "20%");
368
// Shard size for page cache, the value must be power of two.
369
// It's recommended to set it to a value close to the number of BE cores in order to reduce lock contentions.
370
DEFINE_Int32(storage_page_cache_shard_size, "256");
371
// Percentage for index page cache
372
// all storage page cache will be divided into data_page_cache and index_page_cache
373
DEFINE_Int32(index_page_cache_percentage, "10");
374
// whether to disable page cache feature in storage
375
DEFINE_mBool(disable_storage_page_cache, "false");
376
// whether to disable row cache feature in storage
377
DEFINE_mBool(disable_storage_row_cache, "true");
378
// whether to disable pk page cache feature in storage
379
DEFINE_Bool(disable_pk_storage_page_cache, "false");
380
381
// Cache for mow primary key storage page size
382
DEFINE_String(pk_storage_page_cache_limit, "10%");
383
// data page size for primary key index
384
DEFINE_Int32(primary_key_data_page_size, "32768");
385
386
DEFINE_mInt32(data_page_cache_stale_sweep_time_sec, "300");
387
DEFINE_mInt32(index_page_cache_stale_sweep_time_sec, "600");
388
DEFINE_mInt32(pk_index_page_cache_stale_sweep_time_sec, "600");
389
390
DEFINE_Bool(enable_low_cardinality_optimize, "true");
391
DEFINE_Bool(enable_low_cardinality_cache_code, "true");
392
393
// be policy
394
// whether check compaction checksum
395
DEFINE_mBool(enable_compaction_checksum, "false");
396
// whether disable automatic compaction task
397
DEFINE_mBool(disable_auto_compaction, "false");
398
// whether enable vertical compaction
399
DEFINE_mBool(enable_vertical_compaction, "true");
400
// whether enable ordered data compaction
401
DEFINE_mBool(enable_ordered_data_compaction, "true");
402
// In vertical compaction, column number for every group
403
DEFINE_mInt32(vertical_compaction_num_columns_per_group, "5");
404
// In vertical compaction, max memory usage for row_source_buffer
405
DEFINE_Int32(vertical_compaction_max_row_source_memory_mb, "200");
406
// In vertical compaction, max dest segment file size
407
DEFINE_mInt64(vertical_compaction_max_segment_size, "1073741824");
408
409
// If enabled, segments will be flushed column by column
410
DEFINE_mBool(enable_vertical_segment_writer, "true");
411
412
// In ordered data compaction, min segment size for input rowset
413
DEFINE_mInt32(ordered_data_compaction_min_segment_size, "10485760");
414
415
// This config can be set to limit thread number in compaction thread pool.
416
DEFINE_mInt32(max_base_compaction_threads, "4");
417
DEFINE_mInt32(max_cumu_compaction_threads, "-1");
418
DEFINE_mInt32(max_single_replica_compaction_threads, "-1");
419
420
DEFINE_Bool(enable_base_compaction_idle_sched, "true");
421
DEFINE_mInt64(base_compaction_min_rowset_num, "5");
422
DEFINE_mInt64(base_compaction_max_compaction_score, "20");
423
DEFINE_mDouble(base_compaction_min_data_ratio, "0.3");
424
DEFINE_mInt64(base_compaction_dup_key_max_file_size_mbytes, "1024");
425
426
DEFINE_Bool(enable_skip_tablet_compaction, "true");
427
// output rowset of cumulative compaction total disk size exceed this config size,
428
// this rowset will be given to base compaction, unit is m byte.
429
DEFINE_mInt64(compaction_promotion_size_mbytes, "1024");
430
431
// output rowset of cumulative compaction total disk size exceed this config ratio of
432
// base rowset's total disk size, this rowset will be given to base compaction. The value must be between
433
// 0 and 1.
434
DEFINE_mDouble(compaction_promotion_ratio, "0.05");
435
436
// the smallest size of rowset promotion. When the rowset is less than this config, this
437
// rowset will be not given to base compaction. The unit is m byte.
438
DEFINE_mInt64(compaction_promotion_min_size_mbytes, "128");
439
440
// When output rowset of cumulative compaction total version count (end_version - start_version)
441
// exceed this config count, the rowset will be moved to base compaction
442
// NOTE: this config will work for unique key merge-on-write table only, to reduce version count
443
// related cost on delete bitmap more effectively.
444
DEFINE_mInt64(compaction_promotion_version_count, "1000");
445
446
// The lower bound size to do cumulative compaction. When total disk size of candidate rowsets is less than
447
// this size, size_based policy may not do to cumulative compaction. The unit is m byte.
448
DEFINE_mInt64(compaction_min_size_mbytes, "64");
449
450
// cumulative compaction policy: min and max delta file's number
451
DEFINE_mInt64(cumulative_compaction_min_deltas, "5");
452
DEFINE_mInt64(cumulative_compaction_max_deltas, "1000");
453
DEFINE_mInt32(cumulative_compaction_max_deltas_factor, "10");
454
455
// This config can be set to limit thread number in  multiget thread pool.
456
DEFINE_mInt32(multi_get_max_threads, "10");
457
458
// The upper limit of "permits" held by all compaction tasks. This config can be set to limit memory consumption for compaction.
459
DEFINE_mInt64(total_permits_for_compaction_score, "10000");
460
461
// sleep interval in ms after generated compaction tasks
462
DEFINE_mInt32(generate_compaction_tasks_interval_ms, "10");
463
464
// sleep interval in second after update replica infos
465
DEFINE_mInt32(update_replica_infos_interval_seconds, "60");
466
467
// Compaction task number per disk.
468
// Must be greater than 2, because Base compaction and Cumulative compaction have at least one thread each.
469
DEFINE_mInt32(compaction_task_num_per_disk, "4");
470
// compaction thread num for fast disk(typically .SSD), must be greater than 2.
471
DEFINE_mInt32(compaction_task_num_per_fast_disk, "8");
472
DEFINE_Validator(compaction_task_num_per_disk,
473
                 [](const int config) -> bool { return config >= 2; });
474
DEFINE_Validator(compaction_task_num_per_fast_disk,
475
                 [](const int config) -> bool { return config >= 2; });
476
DEFINE_Validator(low_priority_compaction_task_num_per_disk,
477
                 [](const int config) -> bool { return config >= 2; });
478
479
// How many rounds of cumulative compaction for each round of base compaction when compaction tasks generation.
480
DEFINE_mInt32(cumulative_compaction_rounds_for_each_base_compaction_round, "9");
481
482
// Not compact the invisible versions, but with some limitations:
483
// if not timeout, keep no more than compaction_keep_invisible_version_max_count versions;
484
// if timeout, keep no more than compaction_keep_invisible_version_min_count versions.
485
DEFINE_mInt32(compaction_keep_invisible_version_timeout_sec, "1800");
486
DEFINE_mInt32(compaction_keep_invisible_version_min_count, "50");
487
DEFINE_mInt32(compaction_keep_invisible_version_max_count, "500");
488
489
// Threshold to logging compaction trace, in seconds.
490
DEFINE_mInt32(base_compaction_trace_threshold, "60");
491
DEFINE_mInt32(cumulative_compaction_trace_threshold, "10");
492
DEFINE_mBool(disable_compaction_trace_log, "true");
493
494
// Interval to picking rowset to compact, in seconds
495
DEFINE_mInt64(pick_rowset_to_compact_interval_sec, "86400");
496
497
// Compaction priority schedule
498
DEFINE_mBool(enable_compaction_priority_scheduling, "true");
499
DEFINE_mInt32(low_priority_compaction_task_num_per_disk, "2");
500
DEFINE_mInt32(low_priority_compaction_score_threshold, "200");
501
502
// Thread count to do tablet meta checkpoint, -1 means use the data directories count.
503
DEFINE_Int32(max_meta_checkpoint_threads, "-1");
504
505
// Threshold to logging agent task trace, in seconds.
506
DEFINE_mInt32(agent_task_trace_threshold_sec, "2");
507
508
// This config can be set to limit thread number in tablet migration thread pool.
509
DEFINE_Int32(min_tablet_migration_threads, "1");
510
DEFINE_Int32(max_tablet_migration_threads, "1");
511
512
DEFINE_mInt32(finished_migration_tasks_size, "10000");
513
// If size less than this, the remaining rowsets will be force to complete
514
DEFINE_mInt32(migration_remaining_size_threshold_mb, "10");
515
// If the task runs longer than this time, the task will be terminated, in seconds.
516
// timeout = std::max(migration_task_timeout_secs,  tablet size / 1MB/s)
517
DEFINE_mInt32(migration_task_timeout_secs, "300");
518
// timeout for try_lock migration lock
519
DEFINE_Int64(migration_lock_timeout_ms, "1000");
520
521
// Port to start debug webserver on
522
DEFINE_Int32(webserver_port, "8040");
523
// Https enable flag
524
DEFINE_Bool(enable_https, "false");
525
// Path of certificate
526
DEFINE_String(ssl_certificate_path, "");
527
// Path of private key
528
DEFINE_String(ssl_private_key_path, "");
529
// Whether to check authorization
530
DEFINE_Bool(enable_all_http_auth, "false");
531
// Number of webserver workers
532
DEFINE_Int32(webserver_num_workers, "48");
533
534
DEFINE_Bool(enable_single_replica_load, "true");
535
// Number of download workers for single replica load
536
DEFINE_Int32(single_replica_load_download_num_workers, "64");
537
538
// Used for mini Load. mini load data file will be removed after this time.
539
DEFINE_Int64(load_data_reserve_hours, "4");
540
// log error log will be removed after this time
541
DEFINE_mInt64(load_error_log_reserve_hours, "48");
542
// error log size limit, default 200MB
543
DEFINE_mInt64(load_error_log_limit_bytes, "209715200");
544
545
DEFINE_Int32(brpc_heavy_work_pool_threads, "-1");
546
DEFINE_Int32(brpc_light_work_pool_threads, "-1");
547
DEFINE_Int32(brpc_heavy_work_pool_max_queue_size, "-1");
548
DEFINE_Int32(brpc_light_work_pool_max_queue_size, "-1");
549
DEFINE_Int32(brpc_arrow_flight_work_pool_threads, "-1");
550
DEFINE_Int32(brpc_arrow_flight_work_pool_max_queue_size, "-1");
551
552
//Enable brpc builtin services, see:
553
//https://brpc.apache.org/docs/server/basics/#disable-built-in-services-completely
554
DEFINE_Bool(enable_brpc_builtin_services, "true");
555
556
// Enable brpc connection check
557
DEFINE_Bool(enable_brpc_connection_check, "false");
558
559
// The maximum amount of data that can be processed by a stream load
560
DEFINE_mInt64(streaming_load_max_mb, "102400");
561
// Some data formats, such as JSON, cannot be streamed.
562
// Therefore, it is necessary to limit the maximum number of
563
// such data when using stream load to prevent excessive memory consumption.
564
DEFINE_mInt64(streaming_load_json_max_mb, "100");
565
// the alive time of a TabletsChannel.
566
// If the channel does not receive any data till this time,
567
// the channel will be removed.
568
DEFINE_mInt32(streaming_load_rpc_max_alive_time_sec, "1200");
569
// the timeout of a rpc to open the tablet writer in remote BE.
570
// short operation time, can set a short timeout
571
DEFINE_Int32(tablet_writer_open_rpc_timeout_sec, "60");
572
// You can ignore brpc error '[E1011]The server is overcrowded' when writing data.
573
DEFINE_mBool(tablet_writer_ignore_eovercrowded, "true");
574
DEFINE_mBool(exchange_sink_ignore_eovercrowded, "true");
575
DEFINE_mInt32(slave_replica_writer_rpc_timeout_sec, "60");
576
// Whether to enable stream load record function, the default is false.
577
// False: disable stream load record
578
DEFINE_mBool(enable_stream_load_record, "false");
579
// batch size of stream load record reported to FE
580
DEFINE_mInt32(stream_load_record_batch_size, "50");
581
// expire time of stream load record in rocksdb.
582
DEFINE_Int32(stream_load_record_expire_time_secs, "28800");
583
// time interval to clean expired stream load records
584
DEFINE_mInt64(clean_stream_load_record_interval_secs, "1800");
585
// The buffer size to store stream table function schema info
586
DEFINE_Int64(stream_tvf_buffer_size, "1048576"); // 1MB
587
588
// OlapTableSink sender's send interval, should be less than the real response time of a tablet writer rpc.
589
// You may need to lower the speed when the sink receiver bes are too busy.
590
DEFINE_mInt32(olap_table_sink_send_interval_microseconds, "1000");
591
DEFINE_mDouble(olap_table_sink_send_interval_auto_partition_factor, "0.001");
592
593
// Fragment thread pool
594
DEFINE_Int32(fragment_pool_thread_num_min, "64");
595
DEFINE_Int32(fragment_pool_thread_num_max, "2048");
596
DEFINE_Int32(fragment_pool_queue_size, "4096");
597
598
// Control the number of disks on the machine.  If 0, this comes from the system settings.
599
DEFINE_Int32(num_disks, "0");
600
// The maximum number of the threads per disk is also the max queue depth per disk.
601
DEFINE_Int32(num_threads_per_disk, "0");
602
// The read size is the size of the reads sent to os.
603
// There is a trade off of latency and throughout, trying to keep disks busy but
604
// not introduce seeks.  The literature seems to agree that with 8 MB reads, random
605
// io and sequential io perform similarly.
606
DEFINE_Int32(read_size, "8388608");    // 8 * 1024 * 1024, Read Size (in bytes)
607
DEFINE_Int32(min_buffer_size, "1024"); // 1024, The minimum read buffer size (in bytes)
608
609
// for pprof
610
DEFINE_String(pprof_profile_dir, "${DORIS_HOME}/log");
611
// for jeprofile in jemalloc
612
DEFINE_mString(jeprofile_dir, "${DORIS_HOME}/log");
613
DEFINE_mBool(enable_je_purge_dirty_pages, "true");
614
DEFINE_mString(je_dirty_pages_mem_limit_percent, "5%");
615
616
// to forward compatibility, will be removed later
617
DEFINE_mBool(enable_token_check, "true");
618
619
// to open/close system metrics
620
DEFINE_Bool(enable_system_metrics, "true");
621
622
// Number of cores Doris will used, this will effect only when it's greater than 0.
623
// Otherwise, Doris will use all cores returned from "/proc/cpuinfo".
624
DEFINE_Int32(num_cores, "0");
625
626
// When BE start, If there is a broken disk, BE process will exit by default.
627
// Otherwise, we will ignore the broken disk,
628
DEFINE_Bool(ignore_broken_disk, "false");
629
630
// Sleep time in milliseconds between memory maintenance iterations
631
DEFINE_mInt32(memory_maintenance_sleep_time_ms, "100");
632
633
// After full gc, no longer full gc and minor gc during sleep.
634
// After minor gc, no minor gc during sleep, but full gc is possible.
635
DEFINE_mInt32(memory_gc_sleep_time_ms, "500");
636
637
// Sleep time in milliseconds between memtbale flush mgr refresh iterations
638
DEFINE_mInt64(memtable_mem_tracker_refresh_interval_ms, "5");
639
640
DEFINE_mInt64(wg_weighted_memory_ratio_refresh_interval_ms, "50");
641
642
// percent of (active memtables size / all memtables size) when reach hard limit
643
DEFINE_mInt32(memtable_hard_limit_active_percent, "50");
644
645
// percent of (active memtables size / all memtables size) when reach soft limit
646
DEFINE_mInt32(memtable_soft_limit_active_percent, "50");
647
648
// memtable insert memory tracker will multiply input block size with this ratio
649
DEFINE_mDouble(memtable_insert_memory_ratio, "1.4");
650
// max write buffer size before flush, default 200MB
651
DEFINE_mInt64(write_buffer_size, "209715200");
652
// max buffer size used in memtable for the aggregated table, default 400MB
653
DEFINE_mInt64(write_buffer_size_for_agg, "419430400");
654
// max parallel flush task per memtable writer
655
DEFINE_mInt32(memtable_flush_running_count_limit, "2");
656
657
DEFINE_Int32(load_process_max_memory_limit_percent, "50"); // 50%
658
659
// If the memory consumption of load jobs exceed load_process_max_memory_limit,
660
// all load jobs will hang there to wait for memtable flush. We should have a
661
// soft limit which can trigger the memtable flush for the load channel who
662
// consumes lagest memory size before we reach the hard limit. The soft limit
663
// might avoid all load jobs hang at the same time.
664
DEFINE_Int32(load_process_soft_mem_limit_percent, "80");
665
666
// If load memory consumption is within load_process_safe_mem_permit_percent,
667
// memtable memory limiter will do nothing.
668
DEFINE_Int32(load_process_safe_mem_permit_percent, "5");
669
670
// result buffer cancelled time (unit: second)
671
DEFINE_mInt32(result_buffer_cancelled_interval_time, "300");
672
673
// arrow flight result sink buffer rows size, default 4096 * 8
674
DEFINE_mInt32(arrow_flight_result_sink_buffer_size_rows, "32768");
675
// The timeout for ADBC Client to wait for data using arrow flight reader.
676
// If the query is very complex and no result is generated after this time, consider increasing this timeout.
677
DEFINE_mInt32(arrow_flight_reader_brpc_controller_timeout_ms, "300000");
678
679
// the increased frequency of priority for remaining tasks in BlockingPriorityQueue
680
DEFINE_mInt32(priority_queue_remaining_tasks_increased_frequency, "512");
681
682
// sync tablet_meta when modifying meta
683
DEFINE_mBool(sync_tablet_meta, "false");
684
685
// default thrift rpc timeout ms
686
DEFINE_mInt32(thrift_rpc_timeout_ms, "60000");
687
688
// txn commit rpc timeout
689
DEFINE_mInt32(txn_commit_rpc_timeout_ms, "60000");
690
691
// If set to true, metric calculator will run
692
DEFINE_Bool(enable_metric_calculator, "true");
693
694
// max consumer num in one data consumer group, for routine load
695
DEFINE_mInt32(max_consumer_num_per_group, "3");
696
697
// the max size of thread pool for routine load task.
698
// this should be larger than FE config 'max_routine_load_task_num_per_be' (default 5)
699
DEFINE_Int32(max_routine_load_thread_pool_size, "1024");
700
701
// max external scan cache batch count, means cache max_memory_cache_batch_count * batch_size row
702
// default is 20, batch_size's default value is 1024 means 20 * 1024 rows will be cached
703
DEFINE_mInt32(max_memory_sink_batch_count, "20");
704
705
// This configuration is used for the context gc thread schedule period
706
// note: unit is minute, default is 5min
707
DEFINE_mInt32(scan_context_gc_interval_min, "5");
708
709
// es scroll keep-alive
710
DEFINE_String(es_scroll_keepalive, "5m");
711
712
// HTTP connection timeout for es
713
DEFINE_mInt32(es_http_timeout_ms, "5000");
714
715
// the max client cache number per each host
716
// There are variety of client cache in BE, but currently we use the
717
// same cache size configuration.
718
// TODO(cmy): use different config to set different client cache if necessary.
719
DEFINE_Int32(max_client_cache_size_per_host, "10");
720
721
// Dir to save files downloaded by SmallFileMgr
722
DEFINE_String(small_file_dir, "${DORIS_HOME}/lib/small_file/");
723
// path gc
724
DEFINE_Bool(path_gc_check, "true");
725
DEFINE_mInt32(path_gc_check_interval_second, "86400");
726
DEFINE_mInt32(path_gc_check_step, "1000");
727
DEFINE_mInt32(path_gc_check_step_interval_ms, "10");
728
729
// The following 2 configs limit the max usage of disk capacity of a data dir.
730
// If both of these 2 threshold reached, no more data can be writen into that data dir.
731
// The percent of max used capacity of a data dir
732
DEFINE_mInt32(storage_flood_stage_usage_percent, "90"); // 90%
733
// The min bytes that should be left of a data dir
734
DEFINE_mInt64(storage_flood_stage_left_capacity_bytes, "1073741824"); // 1GB
735
// number of thread for flushing memtable per store
736
DEFINE_Int32(flush_thread_num_per_store, "6");
737
// number of thread for flushing memtable per store, for high priority load task
738
DEFINE_Int32(high_priority_flush_thread_num_per_store, "6");
739
740
DEFINE_Int32(wg_flush_thread_num_per_store, "6");
741
742
// config for tablet meta checkpoint
743
DEFINE_mInt32(tablet_meta_checkpoint_min_new_rowsets_num, "10");
744
DEFINE_mInt32(tablet_meta_checkpoint_min_interval_secs, "600");
745
DEFINE_Int32(generate_tablet_meta_checkpoint_tasks_interval_secs, "600");
746
747
// config for default rowset type
748
// Valid configs: ALPHA, BETA
749
DEFINE_String(default_rowset_type, "BETA");
750
751
// Maximum size of a single message body in all protocols
752
DEFINE_Int64(brpc_max_body_size, "3147483648");
753
DEFINE_Int64(brpc_socket_max_unwritten_bytes, "-1");
754
// TODO(zxy): expect to be true in v1.3
755
// Whether to embed the ProtoBuf Request serialized string together with Tuple/Block data into
756
// Controller Attachment and send it through http brpc when the length of the Tuple/Block data
757
// is greater than 1.8G. This is to avoid the error of Request length overflow (2G).
758
DEFINE_mBool(transfer_large_data_by_brpc, "true");
759
760
// max number of txns for every txn_partition_map in txn manager
761
// this is a self protection to avoid too many txns saving in manager
762
DEFINE_mInt64(max_runnings_transactions_per_txn_map, "2000");
763
764
// tablet_map_lock shard size, the value is 2^n, n=0,1,2,3,4
765
// this is a an enhancement for better performance to manage tablet
766
DEFINE_Int32(tablet_map_shard_size, "256");
767
768
// txn_map_lock shard size, the value is 2^n, n=0,1,2,3,4
769
// this is a an enhancement for better performance to manage txn
770
DEFINE_Int32(txn_map_shard_size, "1024");
771
772
// txn_lock shard size, the value is 2^n, n=0,1,2,3,4
773
// this is a an enhancement for better performance to commit and publish txn
774
DEFINE_Int32(txn_shard_size, "1024");
775
776
// Whether to continue to start be when load tablet from header failed.
777
DEFINE_Bool(ignore_load_tablet_failure, "false");
778
779
// Whether to continue to start be when load tablet from header failed.
780
DEFINE_mBool(ignore_rowset_stale_unconsistent_delete, "false");
781
782
// Set max cache's size of query results, the unit is M byte
783
DEFINE_Int32(query_cache_max_size_mb, "256");
784
785
// Cache memory is pruned when reach query_cache_max_size_mb + query_cache_elasticity_size_mb
786
DEFINE_Int32(query_cache_elasticity_size_mb, "128");
787
788
// Maximum number of cache partitions corresponding to a SQL
789
DEFINE_Int32(query_cache_max_partition_count, "1024");
790
791
// Maximum number of version of a tablet. If the version num of a tablet exceed limit,
792
// the load process will reject new incoming load job of this tablet.
793
// This is to avoid too many version num.
794
DEFINE_mInt32(max_tablet_version_num, "2000");
795
796
// Frontend mainly use two thrift sever type: THREAD_POOL, THREADED_SELECTOR. if fe use THREADED_SELECTOR model for thrift server,
797
// the thrift_server_type_of_fe should be set THREADED_SELECTOR to make be thrift client to fe constructed with TFramedTransport
798
DEFINE_String(thrift_server_type_of_fe, "THREAD_POOL");
799
800
// disable zone map index when page row is too few
801
DEFINE_mInt32(zone_map_row_num_threshold, "20");
802
803
// aws sdk log level
804
//    Off = 0,
805
//    Fatal = 1,
806
//    Error = 2,
807
//    Warn = 3,
808
//    Info = 4,
809
//    Debug = 5,
810
//    Trace = 6
811
// Default to turn off aws sdk log, because aws sdk errors that need to be cared will be output through Doris logs
812
DEFINE_Int32(aws_log_level, "0");
813
814
// the buffer size when read data from remote storage like s3
815
DEFINE_mInt32(remote_storage_read_buffer_mb, "16");
816
817
// The minimum length when TCMalloc Hook consumes/releases MemTracker, consume size
818
// smaller than this value will continue to accumulate. specified as number of bytes.
819
// Decreasing this value will increase the frequency of consume/release.
820
// Increasing this value will cause MemTracker statistics to be inaccurate.
821
DEFINE_mInt32(mem_tracker_consume_min_size_bytes, "1048576");
822
823
// The version information of the tablet will be stored in the memory
824
// in an adjacency graph data structure.
825
// And as the new version is written and the old version is deleted,
826
// the data structure will begin to have empty vertex with no edge associations(orphan vertex).
827
// This config is used to control that when the proportion of orphan vertex is greater than the threshold,
828
// the adjacency graph will be rebuilt to ensure that the data structure will not expand indefinitely.
829
// This config usually only needs to be modified during testing.
830
// In most cases, it does not need to be modified.
831
DEFINE_mDouble(tablet_version_graph_orphan_vertex_ratio, "0.1");
832
833
// share delta writers when memtable_on_sink_node = true
834
DEFINE_Bool(share_delta_writers, "true");
835
// timeout for open load stream rpc in ms
836
DEFINE_Int64(open_load_stream_timeout_ms, "60000"); // 60s
837
// enable write background when using brpc stream
838
DEFINE_mBool(enable_brpc_stream_write_background, "true");
839
840
// brpc streaming max_buf_size in bytes
841
DEFINE_Int64(load_stream_max_buf_size, "20971520"); // 20MB
842
// brpc streaming messages_in_batch
843
DEFINE_Int32(load_stream_messages_in_batch, "128");
844
// brpc streaming StreamWait seconds on EAGAIN
845
DEFINE_Int32(load_stream_eagain_wait_seconds, "600");
846
// max tasks per flush token in load stream
847
DEFINE_Int32(load_stream_flush_token_max_tasks, "15");
848
// max wait flush token time in load stream
849
DEFINE_Int32(load_stream_max_wait_flush_token_time_ms, "600000");
850
851
// max send batch parallelism for OlapTableSink
852
// The value set by the user for send_batch_parallelism is not allowed to exceed max_send_batch_parallelism_per_job,
853
// if exceed, the value of send_batch_parallelism would be max_send_batch_parallelism_per_job
854
DEFINE_mInt32(max_send_batch_parallelism_per_job, "5");
855
DEFINE_Validator(max_send_batch_parallelism_per_job,
856
                 [](const int config) -> bool { return config >= 1; });
857
858
// number of send batch thread pool size
859
DEFINE_Int32(send_batch_thread_pool_thread_num, "64");
860
// number of send batch thread pool queue size
861
DEFINE_Int32(send_batch_thread_pool_queue_size, "102400");
862
863
// Limit the number of segment of a newly created rowset.
864
// The newly created rowset may to be compacted after loading,
865
// so if there are too many segment in a rowset, the compaction process
866
// will run out of memory.
867
// When doing compaction, each segment may take at least 1MB buffer.
868
DEFINE_mInt32(max_segment_num_per_rowset, "1000");
869
DEFINE_mInt32(segment_compression_threshold_kb, "256");
870
871
// The connection timeout when connecting to external table such as odbc table.
872
DEFINE_mInt32(external_table_connect_timeout_sec, "30");
873
874
// Time to clean up useless JDBC connection pool cache
875
DEFINE_mInt32(jdbc_connection_pool_cache_clear_time_sec, "28800");
876
877
// Global bitmap cache capacity for aggregation cache, size in bytes
878
DEFINE_Int64(delete_bitmap_agg_cache_capacity, "104857600");
879
// The default delete bitmap cache is set to 100MB,
880
// which can be insufficient and cause performance issues when the amount of user data is large.
881
// To mitigate the problem of an inadequate cache,
882
// we will take the larger of 0.5% of the total memory and 100MB as the delete bitmap cache size.
883
DEFINE_String(delete_bitmap_dynamic_agg_cache_limit, "0.5%");
884
DEFINE_mInt32(delete_bitmap_agg_cache_stale_sweep_time_sec, "1800");
885
886
// reference https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#broker-version-compatibility
887
// If the dependent kafka broker version older than 0.10.0.0,
888
// the value of kafka_api_version_request should be false, and the
889
// value set by the fallback version kafka_broker_version_fallback will be used,
890
// and the valid values are: 0.9.0.x, 0.8.x.y.
891
DEFINE_String(kafka_api_version_request, "true");
892
DEFINE_String(kafka_broker_version_fallback, "0.10.0");
893
DEFINE_String(kafka_debug, "disable");
894
895
// The number of pool siz of routine load consumer.
896
// If you meet the error describe in https://github.com/edenhill/librdkafka/issues/3608
897
// Change this size to 0 to fix it temporarily.
898
DEFINE_mInt32(routine_load_consumer_pool_size, "1024");
899
900
// Used in single-stream-multi-table load. When receive a batch of messages from kafka,
901
// if the size of batch is more than this threshold, we will request plans for all related tables.
902
DEFINE_Int32(multi_table_batch_plan_threshold, "200");
903
904
// Used in single-stream-multi-table load. When receiving a batch of messages from Kafka,
905
// if the size of the table wait for plan is more than this threshold, we will request plans for all related tables.
906
// The param is aimed to avoid requesting and executing too many plans at once.
907
// Performing small batch processing on multiple tables during the loaded process can reduce the pressure of a single RPC
908
// and improve the real-time processing of data.
909
DEFINE_Int32(multi_table_max_wait_tables, "5");
910
911
// When the timeout of a load task is less than this threshold,
912
// Doris treats it as a high priority task.
913
// high priority tasks use a separate thread pool for flush and do not block rpc by memory cleanup logic.
914
// this threshold is mainly used to identify routine load tasks and should not be modified if not necessary.
915
DEFINE_mInt32(load_task_high_priority_threshold_second, "120");
916
917
// The min timeout of load rpc (add batch, close, etc.)
918
// Because a load rpc may be blocked for a while.
919
// Increase this config may avoid rpc timeout.
920
DEFINE_mInt32(min_load_rpc_timeout_ms, "20000");
921
922
// use which protocol to access function service, candicate is baidu_std/h2:grpc
923
DEFINE_String(function_service_protocol, "h2:grpc");
924
925
// use which load balancer to select server to connect
926
DEFINE_String(rpc_load_balancer, "rr");
927
928
// a soft limit of string type length, the hard limit is 2GB - 4, but if too long will cause very low performance,
929
// so we set a soft limit, default is 1MB
930
DEFINE_mInt32(string_type_length_soft_limit_bytes, "1048576");
931
932
DEFINE_Validator(string_type_length_soft_limit_bytes,
933
                 [](const int config) -> bool { return config > 0 && config <= 2147483643; });
934
935
DEFINE_mInt32(jsonb_type_length_soft_limit_bytes, "1048576");
936
937
DEFINE_Validator(jsonb_type_length_soft_limit_bytes,
938
                 [](const int config) -> bool { return config > 0 && config <= 2147483643; });
939
940
// Threshold of reading a small file into memory
941
DEFINE_mInt32(in_memory_file_size, "1048576"); // 1MB
942
943
// ParquetReaderWrap prefetch buffer size
944
DEFINE_Int32(parquet_reader_max_buffer_size, "50");
945
// Max size of parquet page header in bytes
946
DEFINE_mInt32(parquet_header_max_size_mb, "1");
947
// Max buffer size for parquet row group
948
DEFINE_mInt32(parquet_rowgroup_max_buffer_mb, "128");
949
// Max buffer size for parquet chunk column
950
DEFINE_mInt32(parquet_column_max_buffer_mb, "8");
951
DEFINE_mDouble(max_amplified_read_ratio, "0.8");
952
DEFINE_mInt32(merged_oss_min_io_size, "1048576");
953
DEFINE_mInt32(merged_hdfs_min_io_size, "8192");
954
955
// OrcReader
956
DEFINE_mInt32(orc_natural_read_size_mb, "8");
957
DEFINE_mInt64(big_column_size_buffer, "65535");
958
DEFINE_mInt64(small_column_size_buffer, "100");
959
960
// When the rows number reached this limit, will check the filter rate the of bloomfilter
961
// if it is lower than a specific threshold, the predicate will be disabled.
962
DEFINE_mInt32(rf_predicate_check_row_num, "204800");
963
964
// cooldown task configs
965
DEFINE_Int32(cooldown_thread_num, "5");
966
DEFINE_mInt64(generate_cooldown_task_interval_sec, "20");
967
DEFINE_mInt32(remove_unused_remote_files_interval_sec, "21600"); // 6h
968
DEFINE_mInt32(confirm_unused_remote_files_interval_sec, "60");
969
DEFINE_Int32(cold_data_compaction_thread_num, "2");
970
DEFINE_mInt32(cold_data_compaction_interval_sec, "1800");
971
972
DEFINE_String(tmp_file_dir, "tmp");
973
974
DEFINE_Int32(s3_transfer_executor_pool_size, "2");
975
976
DEFINE_Bool(enable_time_lut, "true");
977
DEFINE_mBool(enable_simdjson_reader, "true");
978
979
DEFINE_mBool(enable_query_like_bloom_filter, "true");
980
// number of s3 scanner thread pool size
981
DEFINE_Int32(doris_remote_scanner_thread_pool_thread_num, "48");
982
// number of s3 scanner thread pool queue size
983
DEFINE_Int32(doris_remote_scanner_thread_pool_queue_size, "102400");
984
985
// limit the queue of pending batches which will be sent by a single nodechannel
986
DEFINE_mInt64(nodechannel_pending_queue_max_bytes, "67108864");
987
988
// The batch size for sending data by brpc streaming client
989
DEFINE_mInt64(brpc_streaming_client_batch_bytes, "262144");
990
991
// Max waiting time to wait the "plan fragment start" rpc.
992
// If timeout, the fragment will be cancelled.
993
// This parameter is usually only used when the FE loses connection,
994
// and the BE can automatically cancel the relevant fragment after the timeout,
995
// so as to avoid occupying the execution thread for a long time.
996
DEFINE_mInt32(max_fragment_start_wait_time_seconds, "30");
997
998
DEFINE_mInt32(fragment_mgr_cancel_worker_interval_seconds, "1");
999
1000
// Node role tag for backend. Mix role is the default role, and computation role have no
1001
// any tablet.
1002
DEFINE_String(be_node_role, "mix");
1003
1004
// Hide webserver page for safety.
1005
// Hide the be config page for webserver.
1006
DEFINE_Bool(hide_webserver_config_page, "false");
1007
1008
DEFINE_Bool(enable_segcompaction, "true");
1009
1010
// Max number of segments allowed in a single segcompaction task.
1011
DEFINE_Int32(segcompaction_batch_size, "10");
1012
1013
// Max row count allowed in a single source segment, bigger segments will be skipped.
1014
DEFINE_Int32(segcompaction_candidate_max_rows, "1048576");
1015
1016
// Max file size allowed in a single source segment, bigger segments will be skipped.
1017
DEFINE_Int64(segcompaction_candidate_max_bytes, "104857600");
1018
1019
// Max total row count allowed in a single segcompaction task.
1020
DEFINE_Int32(segcompaction_task_max_rows, "1572864");
1021
1022
// Max total file size allowed in a single segcompaction task.
1023
DEFINE_Int64(segcompaction_task_max_bytes, "157286400");
1024
1025
// Global segcompaction thread pool size.
1026
DEFINE_mInt32(segcompaction_num_threads, "5");
1027
1028
// enable java udf and jdbc scannode
1029
DEFINE_Bool(enable_java_support, "true");
1030
1031
// Set config randomly to check more issues in github workflow
1032
DEFINE_Bool(enable_fuzzy_mode, "false");
1033
1034
DEFINE_Bool(enable_debug_points, "false");
1035
1036
DEFINE_Int32(pipeline_executor_size, "0");
1037
DEFINE_Bool(enable_workload_group_for_scan, "false");
1038
DEFINE_mInt64(workload_group_scan_task_wait_timeout_ms, "10000");
1039
1040
DEFINE_mBool(variant_enable_flatten_nested, "false");
1041
DEFINE_mDouble(variant_ratio_of_defaults_as_sparse_column, "1");
1042
DEFINE_mInt64(variant_threshold_rows_to_estimate_sparse_column, "2048");
1043
DEFINE_mBool(variant_throw_exeception_on_invalid_json, "false");
1044
1045
// block file cache
1046
DEFINE_Bool(enable_file_cache, "false");
1047
// format: [{"path":"/path/to/file_cache","total_size":21474836480,"query_limit":10737418240}]
1048
// format: [{"path":"/path/to/file_cache","total_size":21474836480,"query_limit":10737418240},{"path":"/path/to/file_cache2","total_size":21474836480,"query_limit":10737418240}]
1049
DEFINE_String(file_cache_path, "");
1050
// thread will sleep 10ms per scan file num to limit IO
1051
DEFINE_Int64(async_file_cache_init_file_num_interval, "1000");
1052
DEFINE_Int64(async_file_cache_init_sleep_interval_ms, "20");
1053
DEFINE_Int64(file_cache_max_file_segment_size, "4194304"); // 4MB
1054
// 4KB <= file_cache_max_file_segment_size <= 256MB
1055
DEFINE_Validator(file_cache_max_file_segment_size, [](const int64_t config) -> bool {
1056
    return config >= 4096 && config <= 268435456;
1057
});
1058
DEFINE_Int64(file_cache_min_file_segment_size, "1048576"); // 1MB
1059
// 4KB <= file_cache_min_file_segment_size <= 256MB
1060
DEFINE_Validator(file_cache_min_file_segment_size, [](const int64_t config) -> bool {
1061
    return config >= 4096 && config <= 268435456 &&
1062
           config <= config::file_cache_max_file_segment_size;
1063
});
1064
DEFINE_Bool(clear_file_cache, "false");
1065
DEFINE_Bool(enable_file_cache_query_limit, "false");
1066
DEFINE_mInt32(file_cache_wait_sec_after_fail, "0"); // // zero for no waiting and retrying
1067
DEFINE_mInt32(file_cache_max_evict_num_per_round, "5000");
1068
1069
DEFINE_mInt32(index_cache_entry_stay_time_after_lookup_s, "1800");
1070
DEFINE_mInt32(inverted_index_cache_stale_sweep_time_sec, "600");
1071
// inverted index searcher cache size
1072
DEFINE_String(inverted_index_searcher_cache_limit, "10%");
1073
// set `true` to enable insert searcher into cache when write inverted index data
1074
DEFINE_Bool(enable_write_index_searcher_cache, "true");
1075
DEFINE_Bool(enable_inverted_index_cache_check_timestamp, "true");
1076
DEFINE_Int32(inverted_index_fd_number_limit_percent, "20"); // 20%
1077
DEFINE_Int32(inverted_index_query_cache_shards, "256");
1078
1079
// inverted index match bitmap cache size
1080
DEFINE_String(inverted_index_query_cache_limit, "10%");
1081
1082
// inverted index
1083
DEFINE_mDouble(inverted_index_ram_buffer_size, "512");
1084
// -1 indicates not working.
1085
// Normally we should not change this, it's useful for testing.
1086
DEFINE_mInt32(inverted_index_max_buffered_docs, "-1");
1087
// dict path for chinese analyzer
1088
DEFINE_String(inverted_index_dict_path, "${DORIS_HOME}/dict");
1089
DEFINE_Int32(inverted_index_read_buffer_size, "4096");
1090
// tree depth for bkd index
1091
DEFINE_Int32(max_depth_in_bkd_tree, "32");
1092
// index compaction
1093
DEFINE_mBool(inverted_index_compaction_enable, "false");
1094
// Only for debug, do not use in production
1095
DEFINE_mBool(debug_inverted_index_compaction, "false");
1096
// index by RAM directory
1097
DEFINE_mBool(inverted_index_ram_dir_enable, "true");
1098
// use num_broadcast_buffer blocks as buffer to do broadcast
1099
DEFINE_Int32(num_broadcast_buffer, "32");
1100
1101
// max depth of expression tree allowed.
1102
DEFINE_Int32(max_depth_of_expr_tree, "600");
1103
1104
// Report a tablet as bad when io errors occurs more than this value.
1105
DEFINE_mInt64(max_tablet_io_errors, "-1");
1106
1107
// Report a tablet as bad when its path not found
1108
DEFINE_Int32(tablet_path_check_interval_seconds, "-1");
1109
DEFINE_mInt32(tablet_path_check_batch_size, "1000");
1110
1111
// it must be larger than or equal to 5MB
1112
DEFINE_mInt32(s3_write_buffer_size, "5242880");
1113
// The timeout config for S3 buffer allocation
1114
DEFINE_mInt32(s3_writer_buffer_allocation_timeout, "300");
1115
DEFINE_mInt64(file_cache_max_file_reader_cache_size, "1000000");
1116
1117
//disable shrink memory by default
1118
DEFINE_mBool(enable_shrink_memory, "false");
1119
DEFINE_mInt32(schema_cache_capacity, "1024");
1120
DEFINE_mInt32(schema_cache_sweep_time_sec, "100");
1121
1122
// max number of segment cache, default -1 for backward compatibility fd_number*2/5
1123
DEFINE_Int32(segment_cache_capacity, "-1");
1124
DEFINE_Int32(segment_cache_fd_percentage, "20");
1125
DEFINE_mInt32(estimated_mem_per_column_reader, "512");
1126
DEFINE_Int32(segment_cache_memory_percentage, "5");
1127
1128
// enable feature binlog, default false
1129
DEFINE_Bool(enable_feature_binlog, "false");
1130
1131
// enable set in BitmapValue
1132
DEFINE_Bool(enable_set_in_bitmap_value, "false");
1133
1134
DEFINE_Int64(max_hdfs_file_handle_cache_num, "1000");
1135
DEFINE_Int32(max_hdfs_file_handle_cache_time_sec, "3600");
1136
DEFINE_Int64(max_external_file_meta_cache_num, "1000");
1137
DEFINE_mInt32(common_obj_lru_cache_stale_sweep_time_sec, "900");
1138
// Apply delete pred in cumu compaction
1139
DEFINE_mBool(enable_delete_when_cumu_compaction, "false");
1140
1141
// max_write_buffer_number for rocksdb
1142
DEFINE_Int32(rocksdb_max_write_buffer_number, "5");
1143
1144
DEFINE_mBool(allow_zero_date, "false");
1145
DEFINE_Bool(allow_invalid_decimalv2_literal, "false");
1146
DEFINE_mString(kerberos_ccache_path, "");
1147
DEFINE_mString(kerberos_krb5_conf_path, "/etc/krb5.conf");
1148
1149
DEFINE_mString(get_stack_trace_tool, "libunwind");
1150
DEFINE_mString(dwarf_location_info_mode, "FAST");
1151
DEFINE_mBool(enable_address_sanitizers_with_stack_trace, "true");
1152
1153
// the ratio of _prefetch_size/_batch_size in AutoIncIDBuffer
1154
DEFINE_mInt64(auto_inc_prefetch_size_ratio, "10");
1155
1156
// the ratio of _low_level_water_level_mark/_batch_size in AutoIncIDBuffer
1157
DEFINE_mInt64(auto_inc_low_water_level_mark_size_ratio, "3");
1158
1159
// number of threads that fetch auto-inc ranges from FE
1160
DEFINE_mInt64(auto_inc_fetch_thread_num, "3");
1161
// default 4GB
1162
DEFINE_mInt64(lookup_connection_cache_bytes_limit, "4294967296");
1163
1164
// level of compression when using LZ4_HC, whose defalut value is LZ4HC_CLEVEL_DEFAULT
1165
DEFINE_mInt64(LZ4_HC_compression_level, "9");
1166
1167
DEFINE_mBool(enable_merge_on_write_correctness_check, "true");
1168
// rowid conversion correctness check when compaction for mow table
1169
DEFINE_mBool(enable_rowid_conversion_correctness_check, "false");
1170
// missing rows correctness check when compaction for mow table
1171
DEFINE_mBool(enable_missing_rows_correctness_check, "false");
1172
// When the number of missing versions is more than this value, do not directly
1173
// retry the publish and handle it through async publish.
1174
DEFINE_mInt32(mow_publish_max_discontinuous_version_num, "20");
1175
// When the version is not continuous for MOW table in publish phase and the gap between
1176
// current txn's publishing version and the max version of the tablet exceeds this value,
1177
// don't print warning log
1178
DEFINE_mInt32(publish_version_gap_logging_threshold, "200");
1179
1180
// The secure path with user files, used in the `local` table function.
1181
DEFINE_mString(user_files_secure_path, "${DORIS_HOME}");
1182
1183
DEFINE_Int32(fe_expire_duration_seconds, "60");
1184
1185
DEFINE_Int32(grace_shutdown_wait_seconds, "120");
1186
1187
DEFINE_Int16(bitmap_serialize_version, "1");
1188
1189
// group commit config
1190
DEFINE_String(group_commit_wal_path, "");
1191
DEFINE_Int32(group_commit_replay_wal_retry_num, "10");
1192
DEFINE_Int32(group_commit_replay_wal_retry_interval_seconds, "5");
1193
DEFINE_Int32(group_commit_replay_wal_retry_interval_max_seconds, "1800");
1194
DEFINE_Int32(group_commit_relay_wal_threads, "10");
1195
// This config can be set to limit thread number in group commit request fragment thread pool.
1196
DEFINE_Int32(group_commit_insert_threads, "10");
1197
DEFINE_Int32(group_commit_memory_rows_for_max_filter_ratio, "10000");
1198
DEFINE_Bool(wait_internal_group_commit_finish, "false");
1199
// Max size(bytes) of group commit queues, used for mem back pressure, defult 64M.
1200
DEFINE_mInt32(group_commit_queue_mem_limit, "67108864");
1201
// Max size(bytes) or percentage(%) of wal disk usage, used for disk space back pressure, default 10% of the disk available space.
1202
// group_commit_wal_max_disk_limit=1024 or group_commit_wal_max_disk_limit=10% can be automatically identified.
1203
DEFINE_String(group_commit_wal_max_disk_limit, "10%");
1204
DEFINE_Bool(group_commit_wait_replay_wal_finish, "false");
1205
1206
DEFINE_mInt32(scan_thread_nice_value, "0");
1207
DEFINE_mInt32(tablet_schema_cache_recycle_interval, "3600");
1208
DEFINE_mInt32(tablet_schema_cache_capacity, "102400");
1209
1210
DEFINE_Bool(exit_on_exception, "false");
1211
// This config controls whether the s3 file writer would flush cache asynchronously
1212
DEFINE_Bool(enable_flush_file_cache_async, "true");
1213
1214
// cgroup
1215
DEFINE_mString(doris_cgroup_cpu_path, "");
1216
1217
DEFINE_mBool(enable_workload_group_memory_gc, "true");
1218
1219
DEFINE_Bool(ignore_always_true_predicate_for_segment, "true");
1220
1221
// Ingest binlog work pool size, -1 is disable, 0 is hardware concurrency
1222
DEFINE_Int32(ingest_binlog_work_pool_size, "-1");
1223
1224
// Download binlog rate limit, unit is KB/s, 0 means no limit
1225
DEFINE_Int32(download_binlog_rate_limit_kbs, "0");
1226
1227
DEFINE_mInt32(buffered_reader_read_timeout_ms, "600000");
1228
1229
DEFINE_Bool(enable_snapshot_action, "false");
1230
1231
DEFINE_mInt32(variant_max_merged_tablet_schema_size, "2048");
1232
1233
DEFINE_mBool(enable_column_type_check, "true");
1234
// 128 MB
1235
DEFINE_mInt64(local_exchange_buffer_mem_limit, "134217728");
1236
1237
// Default 300s, if its value <= 0, then log is disabled
1238
DEFINE_mInt64(enable_debug_log_timeout_secs, "0");
1239
1240
// Tolerance for the number of partition id 0 in rowset, default 0
1241
DEFINE_Int32(ignore_invalid_partition_id_rowset_num, "0");
1242
1243
DEFINE_mInt32(report_query_statistics_interval_ms, "3000");
1244
// 30s
1245
DEFINE_mInt32(query_statistics_reserve_timeout_ms, "30000");
1246
1247
// consider two high usage disk at the same available level if they do not exceed this diff.
1248
DEFINE_mDouble(high_disk_avail_level_diff_usages, "0.15");
1249
1250
// create tablet in partition random robin idx lru size, default 10000
1251
DEFINE_Int32(partition_disk_index_lru_size, "10000");
1252
// limit the storage space that query spill files can use
1253
DEFINE_String(spill_storage_root_path, "");
1254
DEFINE_String(spill_storage_limit, "20%");    // 20%
1255
DEFINE_mInt32(spill_gc_interval_ms, "2000");  // 2s
1256
DEFINE_mInt32(spill_gc_work_time_ms, "2000"); // 2s
1257
DEFINE_Int32(spill_io_thread_pool_thread_num, "-1");
1258
DEFINE_Validator(spill_io_thread_pool_thread_num, [](const int config) -> bool {
1259
    if (config == -1) {
1260
        CpuInfo::init();
1261
        spill_io_thread_pool_thread_num = std::max(48, CpuInfo::num_cores() * 2);
1262
    }
1263
    return true;
1264
});
1265
DEFINE_Int32(spill_io_thread_pool_queue_size, "102400");
1266
1267
DEFINE_mBool(check_segment_when_build_rowset_meta, "false");
1268
1269
DEFINE_mInt32(max_s3_client_retry, "10");
1270
1271
DEFINE_mInt32(s3_read_base_wait_time_ms, "100");
1272
DEFINE_mInt32(s3_read_max_wait_time_ms, "800");
1273
1274
// ca_cert_file is in this path by default, Normally no modification is required
1275
// ca cert default path is different from different OS
1276
DEFINE_mString(ca_cert_file_paths,
1277
               "/etc/pki/tls/certs/ca-bundle.crt;/etc/ssl/certs/ca-certificates.crt;"
1278
               "/etc/ssl/ca-bundle.pem");
1279
1280
/** Table sink configurations(currently contains only external table types) **/
1281
// Minimum data processed to scale writers in exchange when non partition writing
1282
DEFINE_mInt64(table_sink_non_partition_write_scaling_data_processed_threshold,
1283
              "26214400"); // 25MB
1284
// Minimum data processed to trigger skewed partition rebalancing in exchange when partition writing
1285
DEFINE_mInt64(table_sink_partition_write_min_data_processed_rebalance_threshold,
1286
              "26214400"); // 25MB
1287
// Minimum partition data processed to rebalance writers in exchange when partition writing
1288
DEFINE_mInt64(table_sink_partition_write_min_partition_data_processed_rebalance_threshold,
1289
              "15728640"); // 15MB
1290
// Maximum processed partition nums of per writer when partition writing
1291
DEFINE_mInt32(table_sink_partition_write_max_partition_nums_per_writer, "128");
1292
1293
/** Hive sink configurations **/
1294
DEFINE_mInt64(hive_sink_max_file_size, "1073741824"); // 1GB
1295
1296
/** Iceberg sink configurations **/
1297
DEFINE_mInt64(iceberg_sink_max_file_size, "1073741824"); // 1GB
1298
1299
DEFINE_mInt32(thrift_client_open_num_tries, "1");
1300
1301
DEFINE_mBool(ignore_schema_change_check, "false");
1302
1303
//JVM monitoring enable. To prevent be from crashing due to jvm compatibility issues. The default setting is off.
1304
DEFINE_Bool(enable_jvm_monitor, "false");
1305
1306
// Skip loading stale rowset meta when initializing `TabletMeta` from protobuf
1307
DEFINE_mBool(skip_loading_stale_rowset_meta, "false");
1308
1309
DEFINE_Bool(enable_file_logger, "true");
1310
1311
// The minimum row group size when exporting Parquet files. default 128MB
1312
DEFINE_Int64(min_row_group_size, "134217728");
1313
1314
// The time out milliseconds for remote fetch schema RPC, default 60s
1315
DEFINE_mInt64(fetch_remote_schema_rpc_timeout_ms, "60000");
1316
1317
DEFINE_mInt64(compaction_memory_bytes_limit, "1073741824");
1318
1319
DEFINE_mInt64(compaction_batch_size, "-1");
1320
1321
// If set to false, the parquet reader will not use page index to filter data.
1322
// This is only for debug purpose, in case sometimes the page index
1323
// filter wrong data.
1324
DEFINE_mBool(enable_parquet_page_index, "false");
1325
1326
DEFINE_mBool(ignore_not_found_file_in_external_table, "true");
1327
1328
// Tablet meta size limit after serialization, 1.5GB
1329
DEFINE_mInt64(tablet_meta_serialize_size_limit, "1610612736");
1330
// Protobuf supports a maximum of 2GB, so the size of the tablet meta after serialization must be less than 2GB
1331
// 1717986918 = 2GB * 0.8
1332
DEFINE_Validator(tablet_meta_serialize_size_limit,
1333
                 [](const int64_t config) -> bool { return config < 1717986918; });
1334
1335
DEFINE_mInt64(pipeline_task_leakage_detect_period_secs, "60");
1336
DEFINE_mInt32(snappy_compression_block_size, "262144");
1337
DEFINE_mInt32(lz4_compression_block_size, "262144");
1338
1339
DEFINE_mBool(enable_pipeline_task_leakage_detect, "false");
1340
1341
// clang-format off
1342
#ifdef BE_TEST
1343
// test s3
1344
DEFINE_String(test_s3_resource, "resource");
1345
DEFINE_String(test_s3_ak, "ak");
1346
DEFINE_String(test_s3_sk, "sk");
1347
DEFINE_String(test_s3_endpoint, "endpoint");
1348
DEFINE_String(test_s3_region, "region");
1349
DEFINE_String(test_s3_bucket, "bucket");
1350
DEFINE_String(test_s3_prefix, "prefix");
1351
#endif
1352
// clang-format on
1353
1354
std::map<std::string, Register::Field>* Register::_s_field_map = nullptr;
1355
std::map<std::string, std::function<bool()>>* RegisterConfValidator::_s_field_validator = nullptr;
1356
std::map<std::string, std::string>* full_conf_map = nullptr;
1357
1358
std::mutex custom_conf_lock;
1359
1360
std::mutex mutable_string_config_lock;
1361
1362
// trim string
1363
742
std::string& trim(std::string& s) {
1364
    // rtrim
1365
742
    s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char c) { return !std::isspace(c); })
1366
742
                    .base(),
1367
742
            s.end());
1368
    // ltrim
1369
742
    s.erase(s.begin(),
1370
742
            std::find_if(s.begin(), s.end(), [](unsigned char c) { return !std::isspace(c); }));
1371
742
    return s;
1372
742
}
1373
1374
// split string by '='
1375
25
void splitkv(const std::string& s, std::string& k, std::string& v) {
1376
25
    const char sep = '=';
1377
25
    int start = 0;
1378
25
    int end = 0;
1379
25
    if ((end = s.find(sep, start)) != std::string::npos) {
1380
25
        k = s.substr(start, end - start);
1381
25
        v = s.substr(end + 1);
1382
25
    } else {
1383
0
        k = s;
1384
0
        v = "";
1385
0
    }
1386
25
}
1387
1388
// replace env variables
1389
557
bool replaceenv(std::string& s) {
1390
557
    std::size_t pos = 0;
1391
557
    std::size_t start = 0;
1392
566
    while ((start = s.find("${", pos)) != std::string::npos) {
1393
9
        std::size_t end = s.find('}', start + 2);
1394
9
        if (end == std::string::npos) {
1395
0
            return false;
1396
0
        }
1397
9
        std::string envkey = s.substr(start + 2, end - start - 2);
1398
9
        const char* envval = std::getenv(envkey.c_str());
1399
9
        if (envval == nullptr) {
1400
0
            return false;
1401
0
        }
1402
9
        s.erase(start, end - start + 1);
1403
9
        s.insert(start, envval);
1404
9
        pos = start + strlen(envval);
1405
9
    }
1406
557
    return true;
1407
557
}
1408
1409
bool strtox(const std::string& valstr, bool& retval);
1410
bool strtox(const std::string& valstr, int16_t& retval);
1411
bool strtox(const std::string& valstr, int32_t& retval);
1412
bool strtox(const std::string& valstr, int64_t& retval);
1413
bool strtox(const std::string& valstr, double& retval);
1414
bool strtox(const std::string& valstr, std::string& retval);
1415
1416
template <typename T>
1417
7
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
7
    std::stringstream ss(valstr);
1419
7
    std::string item;
1420
7
    T t;
1421
26
    while (std::getline(ss, item, ',')) {
1422
19
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
19
        retval.push_back(t);
1426
19
    }
1427
7
    return true;
1428
7
}
_ZN5doris6config6strtoxIbEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIT_SaISB_EE
Line
Count
Source
1417
1
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
1
    std::stringstream ss(valstr);
1419
1
    std::string item;
1420
1
    T t;
1421
4
    while (std::getline(ss, item, ',')) {
1422
3
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
3
        retval.push_back(t);
1426
3
    }
1427
1
    return true;
1428
1
}
_ZN5doris6config6strtoxIsEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIT_SaISB_EE
Line
Count
Source
1417
1
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
1
    std::stringstream ss(valstr);
1419
1
    std::string item;
1420
1
    T t;
1421
4
    while (std::getline(ss, item, ',')) {
1422
3
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
3
        retval.push_back(t);
1426
3
    }
1427
1
    return true;
1428
1
}
_ZN5doris6config6strtoxIiEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIT_SaISB_EE
Line
Count
Source
1417
1
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
1
    std::stringstream ss(valstr);
1419
1
    std::string item;
1420
1
    T t;
1421
4
    while (std::getline(ss, item, ',')) {
1422
3
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
3
        retval.push_back(t);
1426
3
    }
1427
1
    return true;
1428
1
}
_ZN5doris6config6strtoxIlEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIT_SaISB_EE
Line
Count
Source
1417
1
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
1
    std::stringstream ss(valstr);
1419
1
    std::string item;
1420
1
    T t;
1421
4
    while (std::getline(ss, item, ',')) {
1422
3
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
3
        retval.push_back(t);
1426
3
    }
1427
1
    return true;
1428
1
}
_ZN5doris6config6strtoxIdEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIT_SaISB_EE
Line
Count
Source
1417
1
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
1
    std::stringstream ss(valstr);
1419
1
    std::string item;
1420
1
    T t;
1421
4
    while (std::getline(ss, item, ',')) {
1422
3
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
3
        retval.push_back(t);
1426
3
    }
1427
1
    return true;
1428
1
}
_ZN5doris6config6strtoxINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKS7_RSt6vectorIT_SaISB_EE
Line
Count
Source
1417
2
bool strtox(const std::string& valstr, std::vector<T>& retval) {
1418
2
    std::stringstream ss(valstr);
1419
2
    std::string item;
1420
2
    T t;
1421
6
    while (std::getline(ss, item, ',')) {
1422
4
        if (!strtox(trim(item), t)) {
1423
0
            return false;
1424
0
        }
1425
4
        retval.push_back(t);
1426
4
    }
1427
2
    return true;
1428
2
}
1429
1430
103
bool strtox(const std::string& valstr, bool& retval) {
1431
103
    if (valstr == "true") {
1432
51
        retval = true;
1433
52
    } else if (valstr == "false") {
1434
51
        retval = false;
1435
51
    } else {
1436
1
        return false;
1437
1
    }
1438
102
    return true;
1439
103
}
1440
1441
template <typename T>
1442
380
bool strtointeger(const std::string& valstr, T& retval) {
1443
380
    if (valstr.length() == 0) {
1444
0
        return false; // empty-string is only allowed for string type.
1445
0
    }
1446
380
    char* end;
1447
380
    errno = 0;
1448
380
    const char* valcstr = valstr.c_str();
1449
380
    int64_t ret64 = strtoll(valcstr, &end, 10);
1450
380
    if (errno || end != valcstr + strlen(valcstr)) {
1451
0
        return false; // bad parse
1452
0
    }
1453
380
    T tmp = retval;
1454
380
    retval = static_cast<T>(ret64);
1455
380
    if (retval != ret64) {
1456
1
        retval = tmp;
1457
1
        return false;
1458
1
    }
1459
379
    return true;
1460
380
}
_ZN5doris6config12strtointegerIsEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1442
10
bool strtointeger(const std::string& valstr, T& retval) {
1443
10
    if (valstr.length() == 0) {
1444
0
        return false; // empty-string is only allowed for string type.
1445
0
    }
1446
10
    char* end;
1447
10
    errno = 0;
1448
10
    const char* valcstr = valstr.c_str();
1449
10
    int64_t ret64 = strtoll(valcstr, &end, 10);
1450
10
    if (errno || end != valcstr + strlen(valcstr)) {
1451
0
        return false; // bad parse
1452
0
    }
1453
10
    T tmp = retval;
1454
10
    retval = static_cast<T>(ret64);
1455
10
    if (retval != ret64) {
1456
0
        retval = tmp;
1457
0
        return false;
1458
0
    }
1459
10
    return true;
1460
10
}
_ZN5doris6config12strtointegerIiEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1442
285
bool strtointeger(const std::string& valstr, T& retval) {
1443
285
    if (valstr.length() == 0) {
1444
0
        return false; // empty-string is only allowed for string type.
1445
0
    }
1446
285
    char* end;
1447
285
    errno = 0;
1448
285
    const char* valcstr = valstr.c_str();
1449
285
    int64_t ret64 = strtoll(valcstr, &end, 10);
1450
285
    if (errno || end != valcstr + strlen(valcstr)) {
1451
0
        return false; // bad parse
1452
0
    }
1453
285
    T tmp = retval;
1454
285
    retval = static_cast<T>(ret64);
1455
285
    if (retval != ret64) {
1456
1
        retval = tmp;
1457
1
        return false;
1458
1
    }
1459
284
    return true;
1460
285
}
_ZN5doris6config12strtointegerIlEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1442
85
bool strtointeger(const std::string& valstr, T& retval) {
1443
85
    if (valstr.length() == 0) {
1444
0
        return false; // empty-string is only allowed for string type.
1445
0
    }
1446
85
    char* end;
1447
85
    errno = 0;
1448
85
    const char* valcstr = valstr.c_str();
1449
85
    int64_t ret64 = strtoll(valcstr, &end, 10);
1450
85
    if (errno || end != valcstr + strlen(valcstr)) {
1451
0
        return false; // bad parse
1452
0
    }
1453
85
    T tmp = retval;
1454
85
    retval = static_cast<T>(ret64);
1455
85
    if (retval != ret64) {
1456
0
        retval = tmp;
1457
0
        return false;
1458
0
    }
1459
85
    return true;
1460
85
}
1461
1462
10
bool strtox(const std::string& valstr, int16_t& retval) {
1463
10
    return strtointeger(valstr, retval);
1464
10
}
1465
1466
285
bool strtox(const std::string& valstr, int32_t& retval) {
1467
285
    return strtointeger(valstr, retval);
1468
285
}
1469
1470
85
bool strtox(const std::string& valstr, int64_t& retval) {
1471
85
    return strtointeger(valstr, retval);
1472
85
}
1473
1474
18
bool strtox(const std::string& valstr, double& retval) {
1475
18
    if (valstr.length() == 0) {
1476
1
        return false; // empty-string is only allowed for string type.
1477
1
    }
1478
17
    char* end = nullptr;
1479
17
    errno = 0;
1480
17
    const char* valcstr = valstr.c_str();
1481
17
    retval = strtod(valcstr, &end);
1482
17
    if (errno || end != valcstr + strlen(valcstr)) {
1483
0
        return false; // bad parse
1484
0
    }
1485
17
    return true;
1486
17
}
1487
1488
68
bool strtox(const std::string& valstr, std::string& retval) {
1489
68
    retval = valstr;
1490
68
    return true;
1491
68
}
1492
1493
template <typename T>
1494
557
bool convert(const std::string& value, T& retval) {
1495
557
    std::string valstr(value);
1496
557
    trim(valstr);
1497
557
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
557
    return strtox(valstr, retval);
1501
557
}
_ZN5doris6config7convertISt6vectorIbSaIbEEEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
1
bool convert(const std::string& value, T& retval) {
1495
1
    std::string valstr(value);
1496
1
    trim(valstr);
1497
1
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
1
    return strtox(valstr, retval);
1501
1
}
_ZN5doris6config7convertISt6vectorIsSaIsEEEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
1
bool convert(const std::string& value, T& retval) {
1495
1
    std::string valstr(value);
1496
1
    trim(valstr);
1497
1
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
1
    return strtox(valstr, retval);
1501
1
}
_ZN5doris6config7convertISt6vectorIiSaIiEEEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
1
bool convert(const std::string& value, T& retval) {
1495
1
    std::string valstr(value);
1496
1
    trim(valstr);
1497
1
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
1
    return strtox(valstr, retval);
1501
1
}
_ZN5doris6config7convertISt6vectorIlSaIlEEEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
1
bool convert(const std::string& value, T& retval) {
1495
1
    std::string valstr(value);
1496
1
    trim(valstr);
1497
1
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
1
    return strtox(valstr, retval);
1501
1
}
_ZN5doris6config7convertISt6vectorIdSaIdEEEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
1
bool convert(const std::string& value, T& retval) {
1495
1
    std::string valstr(value);
1496
1
    trim(valstr);
1497
1
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
1
    return strtox(valstr, retval);
1501
1
}
_ZN5doris6config7convertISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEEEbRKS8_RT_
Line
Count
Source
1494
2
bool convert(const std::string& value, T& retval) {
1495
2
    std::string valstr(value);
1496
2
    trim(valstr);
1497
2
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
2
    return strtox(valstr, retval);
1501
2
}
_ZN5doris6config7convertIbEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
100
bool convert(const std::string& value, T& retval) {
1495
100
    std::string valstr(value);
1496
100
    trim(valstr);
1497
100
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
100
    return strtox(valstr, retval);
1501
100
}
_ZN5doris6config7convertIsEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
7
bool convert(const std::string& value, T& retval) {
1495
7
    std::string valstr(value);
1496
7
    trim(valstr);
1497
7
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
7
    return strtox(valstr, retval);
1501
7
}
_ZN5doris6config7convertIiEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
282
bool convert(const std::string& value, T& retval) {
1495
282
    std::string valstr(value);
1496
282
    trim(valstr);
1497
282
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
282
    return strtox(valstr, retval);
1501
282
}
_ZN5doris6config7convertIlEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
82
bool convert(const std::string& value, T& retval) {
1495
82
    std::string valstr(value);
1496
82
    trim(valstr);
1497
82
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
82
    return strtox(valstr, retval);
1501
82
}
_ZN5doris6config7convertIdEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERT_
Line
Count
Source
1494
15
bool convert(const std::string& value, T& retval) {
1495
15
    std::string valstr(value);
1496
15
    trim(valstr);
1497
15
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
15
    return strtox(valstr, retval);
1501
15
}
_ZN5doris6config7convertINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKS7_RT_
Line
Count
Source
1494
64
bool convert(const std::string& value, T& retval) {
1495
64
    std::string valstr(value);
1496
64
    trim(valstr);
1497
64
    if (!replaceenv(valstr)) {
1498
0
        return false;
1499
0
    }
1500
64
    return strtox(valstr, retval);
1501
64
}
1502
1503
// load conf file
1504
6
bool Properties::load(const char* conf_file, bool must_exist) {
1505
    // if conf_file is null, use the empty props
1506
6
    if (conf_file == nullptr) {
1507
2
        return true;
1508
2
    }
1509
1510
    // open the conf file
1511
4
    std::ifstream input(conf_file);
1512
4
    if (!input.is_open()) {
1513
1
        if (must_exist) {
1514
0
            std::cerr << "config::load() failed to open the file:" << conf_file << std::endl;
1515
0
            return false;
1516
0
        }
1517
1
        return true;
1518
1
    }
1519
1520
    // load properties
1521
3
    std::string line;
1522
3
    std::string key;
1523
3
    std::string value;
1524
3
    line.reserve(512);
1525
119
    while (input) {
1526
        // read one line at a time
1527
116
        std::getline(input, line);
1528
1529
        // remove left and right spaces
1530
116
        trim(line);
1531
1532
        // ignore comments
1533
116
        if (line.empty() || line[0] == '#') {
1534
91
            continue;
1535
91
        }
1536
1537
        // read key and value
1538
25
        splitkv(line, key, value);
1539
25
        trim(key);
1540
25
        trim(value);
1541
1542
        // insert into file_conf_map
1543
25
        file_conf_map[key] = value;
1544
25
    }
1545
1546
    // close the conf file
1547
3
    input.close();
1548
1549
3
    return true;
1550
4
}
1551
1552
template <typename T>
1553
bool Properties::get_or_default(const char* key, const char* defstr, T& retval, bool* is_retval_set,
1554
539
                                std::string& rawval) const {
1555
539
    const auto& it = file_conf_map.find(std::string(key));
1556
539
    std::string valstr;
1557
539
    if (it == file_conf_map.end()) {
1558
524
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
524
        } else {
1563
524
            valstr = std::string(defstr);
1564
524
        }
1565
524
    } else {
1566
15
        valstr = it->second;
1567
15
    }
1568
539
    rawval = valstr;
1569
539
    *is_retval_set = true;
1570
539
    return convert(valstr, retval);
1571
539
}
_ZNK5doris6config10Properties14get_or_defaultIbEEbPKcS4_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
94
                                std::string& rawval) const {
1555
94
    const auto& it = file_conf_map.find(std::string(key));
1556
94
    std::string valstr;
1557
94
    if (it == file_conf_map.end()) {
1558
93
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
93
        } else {
1563
93
            valstr = std::string(defstr);
1564
93
        }
1565
93
    } else {
1566
1
        valstr = it->second;
1567
1
    }
1568
94
    rawval = valstr;
1569
94
    *is_retval_set = true;
1570
94
    return convert(valstr, retval);
1571
94
}
_ZNK5doris6config10Properties14get_or_defaultIsEEbPKcS4_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
3
                                std::string& rawval) const {
1555
3
    const auto& it = file_conf_map.find(std::string(key));
1556
3
    std::string valstr;
1557
3
    if (it == file_conf_map.end()) {
1558
3
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
3
        } else {
1563
3
            valstr = std::string(defstr);
1564
3
        }
1565
3
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
3
    rawval = valstr;
1569
3
    *is_retval_set = true;
1570
3
    return convert(valstr, retval);
1571
3
}
_ZNK5doris6config10Properties14get_or_defaultIiEEbPKcS4_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
280
                                std::string& rawval) const {
1555
280
    const auto& it = file_conf_map.find(std::string(key));
1556
280
    std::string valstr;
1557
280
    if (it == file_conf_map.end()) {
1558
274
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
274
        } else {
1563
274
            valstr = std::string(defstr);
1564
274
        }
1565
274
    } else {
1566
6
        valstr = it->second;
1567
6
    }
1568
280
    rawval = valstr;
1569
280
    *is_retval_set = true;
1570
280
    return convert(valstr, retval);
1571
280
}
_ZNK5doris6config10Properties14get_or_defaultIlEEbPKcS4_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
81
                                std::string& rawval) const {
1555
81
    const auto& it = file_conf_map.find(std::string(key));
1556
81
    std::string valstr;
1557
81
    if (it == file_conf_map.end()) {
1558
81
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
81
        } else {
1563
81
            valstr = std::string(defstr);
1564
81
        }
1565
81
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
81
    rawval = valstr;
1569
81
    *is_retval_set = true;
1570
81
    return convert(valstr, retval);
1571
81
}
_ZNK5doris6config10Properties14get_or_defaultIdEEbPKcS4_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
13
                                std::string& rawval) const {
1555
13
    const auto& it = file_conf_map.find(std::string(key));
1556
13
    std::string valstr;
1557
13
    if (it == file_conf_map.end()) {
1558
13
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
13
        } else {
1563
13
            valstr = std::string(defstr);
1564
13
        }
1565
13
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
13
    rawval = valstr;
1569
13
    *is_retval_set = true;
1570
13
    return convert(valstr, retval);
1571
13
}
_ZNK5doris6config10Properties14get_or_defaultINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbPKcSA_RT_PbRS8_
Line
Count
Source
1554
61
                                std::string& rawval) const {
1555
61
    const auto& it = file_conf_map.find(std::string(key));
1556
61
    std::string valstr;
1557
61
    if (it == file_conf_map.end()) {
1558
53
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
53
        } else {
1563
53
            valstr = std::string(defstr);
1564
53
        }
1565
53
    } else {
1566
8
        valstr = it->second;
1567
8
    }
1568
61
    rawval = valstr;
1569
61
    *is_retval_set = true;
1570
61
    return convert(valstr, retval);
1571
61
}
_ZNK5doris6config10Properties14get_or_defaultISt6vectorIbSaIbEEEEbPKcS7_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
1
                                std::string& rawval) const {
1555
1
    const auto& it = file_conf_map.find(std::string(key));
1556
1
    std::string valstr;
1557
1
    if (it == file_conf_map.end()) {
1558
1
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
1
        } else {
1563
1
            valstr = std::string(defstr);
1564
1
        }
1565
1
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
1
    rawval = valstr;
1569
1
    *is_retval_set = true;
1570
1
    return convert(valstr, retval);
1571
1
}
_ZNK5doris6config10Properties14get_or_defaultISt6vectorIsSaIsEEEEbPKcS7_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
1
                                std::string& rawval) const {
1555
1
    const auto& it = file_conf_map.find(std::string(key));
1556
1
    std::string valstr;
1557
1
    if (it == file_conf_map.end()) {
1558
1
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
1
        } else {
1563
1
            valstr = std::string(defstr);
1564
1
        }
1565
1
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
1
    rawval = valstr;
1569
1
    *is_retval_set = true;
1570
1
    return convert(valstr, retval);
1571
1
}
_ZNK5doris6config10Properties14get_or_defaultISt6vectorIiSaIiEEEEbPKcS7_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
1
                                std::string& rawval) const {
1555
1
    const auto& it = file_conf_map.find(std::string(key));
1556
1
    std::string valstr;
1557
1
    if (it == file_conf_map.end()) {
1558
1
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
1
        } else {
1563
1
            valstr = std::string(defstr);
1564
1
        }
1565
1
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
1
    rawval = valstr;
1569
1
    *is_retval_set = true;
1570
1
    return convert(valstr, retval);
1571
1
}
_ZNK5doris6config10Properties14get_or_defaultISt6vectorIlSaIlEEEEbPKcS7_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
1
                                std::string& rawval) const {
1555
1
    const auto& it = file_conf_map.find(std::string(key));
1556
1
    std::string valstr;
1557
1
    if (it == file_conf_map.end()) {
1558
1
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
1
        } else {
1563
1
            valstr = std::string(defstr);
1564
1
        }
1565
1
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
1
    rawval = valstr;
1569
1
    *is_retval_set = true;
1570
1
    return convert(valstr, retval);
1571
1
}
_ZNK5doris6config10Properties14get_or_defaultISt6vectorIdSaIdEEEEbPKcS7_RT_PbRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Line
Count
Source
1554
1
                                std::string& rawval) const {
1555
1
    const auto& it = file_conf_map.find(std::string(key));
1556
1
    std::string valstr;
1557
1
    if (it == file_conf_map.end()) {
1558
1
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
1
        } else {
1563
1
            valstr = std::string(defstr);
1564
1
        }
1565
1
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
1
    rawval = valstr;
1569
1
    *is_retval_set = true;
1570
1
    return convert(valstr, retval);
1571
1
}
_ZNK5doris6config10Properties14get_or_defaultISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS9_EEEEbPKcSD_RT_PbRS9_
Line
Count
Source
1554
2
                                std::string& rawval) const {
1555
2
    const auto& it = file_conf_map.find(std::string(key));
1556
2
    std::string valstr;
1557
2
    if (it == file_conf_map.end()) {
1558
2
        if (defstr == nullptr) {
1559
            // Not found in conf map, and no default value need to be set, just return
1560
0
            *is_retval_set = false;
1561
0
            return true;
1562
2
        } else {
1563
2
            valstr = std::string(defstr);
1564
2
        }
1565
2
    } else {
1566
0
        valstr = it->second;
1567
0
    }
1568
2
    rawval = valstr;
1569
2
    *is_retval_set = true;
1570
2
    return convert(valstr, retval);
1571
2
}
1572
1573
0
void Properties::set(const std::string& key, const std::string& val) {
1574
0
    file_conf_map.emplace(key, val);
1575
0
}
1576
1577
3
void Properties::set_force(const std::string& key, const std::string& val) {
1578
3
    file_conf_map[key] = val;
1579
3
}
1580
1581
3
Status Properties::dump(const std::string& conffile) {
1582
3
    std::string conffile_tmp = conffile + ".tmp";
1583
3
    io::FileWriterPtr file_writer;
1584
3
    RETURN_IF_ERROR(io::global_local_filesystem()->create_file(conffile_tmp, &file_writer));
1585
3
    RETURN_IF_ERROR(file_writer->append("# THIS IS AN AUTO GENERATED CONFIG FILE.\n"));
1586
3
    RETURN_IF_ERROR(file_writer->append(
1587
3
            "# You can modify this file manually, and the configurations in this file\n"));
1588
3
    RETURN_IF_ERROR(file_writer->append("# will overwrite the configurations in be.conf\n\n"));
1589
1590
3
    for (auto const& iter : file_conf_map) {
1591
3
        RETURN_IF_ERROR(file_writer->append(iter.first));
1592
3
        RETURN_IF_ERROR(file_writer->append(" = "));
1593
3
        RETURN_IF_ERROR(file_writer->append(iter.second));
1594
3
        RETURN_IF_ERROR(file_writer->append("\n"));
1595
3
    }
1596
1597
3
    RETURN_IF_ERROR(file_writer->close());
1598
1599
3
    return io::global_local_filesystem()->rename(conffile_tmp, conffile);
1600
3
}
1601
1602
template <typename T>
1603
6
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
6
    size_t last = v.size() - 1;
1605
25
    for (size_t i = 0; i < v.size(); ++i) {
1606
19
        out << v[i];
1607
19
        if (i != last) {
1608
13
            out << ", ";
1609
13
        }
1610
19
    }
1611
6
    return out;
1612
6
}
_ZN5doris6configlsIbEERSoS2_RKSt6vectorIT_SaIS4_EE
Line
Count
Source
1603
1
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
1
    size_t last = v.size() - 1;
1605
4
    for (size_t i = 0; i < v.size(); ++i) {
1606
3
        out << v[i];
1607
3
        if (i != last) {
1608
2
            out << ", ";
1609
2
        }
1610
3
    }
1611
1
    return out;
1612
1
}
_ZN5doris6configlsIsEERSoS2_RKSt6vectorIT_SaIS4_EE
Line
Count
Source
1603
1
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
1
    size_t last = v.size() - 1;
1605
4
    for (size_t i = 0; i < v.size(); ++i) {
1606
3
        out << v[i];
1607
3
        if (i != last) {
1608
2
            out << ", ";
1609
2
        }
1610
3
    }
1611
1
    return out;
1612
1
}
_ZN5doris6configlsIiEERSoS2_RKSt6vectorIT_SaIS4_EE
Line
Count
Source
1603
1
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
1
    size_t last = v.size() - 1;
1605
4
    for (size_t i = 0; i < v.size(); ++i) {
1606
3
        out << v[i];
1607
3
        if (i != last) {
1608
2
            out << ", ";
1609
2
        }
1610
3
    }
1611
1
    return out;
1612
1
}
_ZN5doris6configlsIlEERSoS2_RKSt6vectorIT_SaIS4_EE
Line
Count
Source
1603
1
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
1
    size_t last = v.size() - 1;
1605
4
    for (size_t i = 0; i < v.size(); ++i) {
1606
3
        out << v[i];
1607
3
        if (i != last) {
1608
2
            out << ", ";
1609
2
        }
1610
3
    }
1611
1
    return out;
1612
1
}
_ZN5doris6configlsIdEERSoS2_RKSt6vectorIT_SaIS4_EE
Line
Count
Source
1603
1
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
1
    size_t last = v.size() - 1;
1605
4
    for (size_t i = 0; i < v.size(); ++i) {
1606
3
        out << v[i];
1607
3
        if (i != last) {
1608
2
            out << ", ";
1609
2
        }
1610
3
    }
1611
1
    return out;
1612
1
}
_ZN5doris6configlsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERSoS8_RKSt6vectorIT_SaISA_EE
Line
Count
Source
1603
1
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
1604
1
    size_t last = v.size() - 1;
1605
5
    for (size_t i = 0; i < v.size(); ++i) {
1606
4
        out << v[i];
1607
4
        if (i != last) {
1608
3
            out << ", ";
1609
3
        }
1610
4
    }
1611
1
    return out;
1612
1
}
1613
1614
#define SET_FIELD(FIELD, TYPE, FILL_CONF_MAP, SET_TO_DEFAULT)                                  \
1615
1.76k
    if (strcmp((FIELD).type, #TYPE) == 0) {                                                    \
1616
539
        TYPE new_value = TYPE();                                                               \
1617
539
        bool is_newval_set = false;                                                            \
1618
539
        std::string raw_value;                                                                 \
1619
539
        if (!props.get_or_default((FIELD).name, ((SET_TO_DEFAULT) ? (FIELD).defval : nullptr), \
1620
539
                                  new_value, &is_newval_set, raw_value)) {                     \
1621
0
            std::cerr << "config field error: " << (FIELD).name << " = \"" << raw_value << '"' \
1622
0
                      << std::endl;                                                            \
1623
0
            return false;                                                                      \
1624
0
        }                                                                                      \
1625
539
        if (!is_newval_set) {                                                                  \
1626
0
            continue;                                                                          \
1627
0
        }                                                                                      \
1628
539
        TYPE& ref_conf_value = *reinterpret_cast<TYPE*>((FIELD).storage);                      \
1629
539
        TYPE old_value = ref_conf_value;                                                       \
1630
539
        ref_conf_value = new_value;                                                            \
1631
539
        if (RegisterConfValidator::_s_field_validator != nullptr) {                            \
1632
539
            auto validator = RegisterConfValidator::_s_field_validator->find((FIELD).name);    \
1633
539
            if (validator != RegisterConfValidator::_s_field_validator->end() &&               \
1634
539
                !(validator->second)()) {                                                      \
1635
0
                ref_conf_value = old_value;                                                    \
1636
0
                std::cerr << "validate " << (FIELD).name << "=" << new_value << " failed"      \
1637
0
                          << std::endl;                                                        \
1638
0
                return false;                                                                  \
1639
0
            }                                                                                  \
1640
539
        }                                                                                      \
1641
539
        if (FILL_CONF_MAP) {                                                                   \
1642
20
            std::ostringstream oss;                                                            \
1643
20
            oss << ref_conf_value;                                                             \
1644
20
            (*full_conf_map)[(FIELD).name] = oss.str();                                        \
1645
20
        }                                                                                      \
1646
539
        continue;                                                                              \
1647
539
    }
1648
1649
// init conf fields
1650
3
bool init(const char* conf_file, bool fill_conf_map, bool must_exist, bool set_to_default) {
1651
3
    Properties props;
1652
    // load properties file
1653
3
    if (!props.load(conf_file, must_exist)) {
1654
0
        return false;
1655
0
    }
1656
    // fill full_conf_map ?
1657
3
    if (fill_conf_map && full_conf_map == nullptr) {
1658
1
        full_conf_map = new std::map<std::string, std::string>();
1659
1
    }
1660
1661
    // set conf fields
1662
539
    for (const auto& it : *Register::_s_field_map) {
1663
539
        SET_FIELD(it.second, bool, fill_conf_map, set_to_default);
1664
445
        SET_FIELD(it.second, int16_t, fill_conf_map, set_to_default);
1665
442
        SET_FIELD(it.second, int32_t, fill_conf_map, set_to_default);
1666
162
        SET_FIELD(it.second, int64_t, fill_conf_map, set_to_default);
1667
81
        SET_FIELD(it.second, double, fill_conf_map, set_to_default);
1668
68
        SET_FIELD(it.second, std::string, fill_conf_map, set_to_default);
1669
7
        SET_FIELD(it.second, std::vector<bool>, fill_conf_map, set_to_default);
1670
6
        SET_FIELD(it.second, std::vector<int16_t>, fill_conf_map, set_to_default);
1671
5
        SET_FIELD(it.second, std::vector<int32_t>, fill_conf_map, set_to_default);
1672
4
        SET_FIELD(it.second, std::vector<int64_t>, fill_conf_map, set_to_default);
1673
3
        SET_FIELD(it.second, std::vector<double>, fill_conf_map, set_to_default);
1674
2
        SET_FIELD(it.second, std::vector<std::string>, fill_conf_map, set_to_default);
1675
0
    }
1676
1677
3
    return true;
1678
3
}
1679
1680
#define UPDATE_FIELD(FIELD, VALUE, TYPE, PERSIST)                                                  \
1681
52
    if (strcmp((FIELD).type, #TYPE) == 0) {                                                        \
1682
18
        TYPE new_value;                                                                            \
1683
18
        if (!convert((VALUE), new_value)) {                                                        \
1684
3
            return Status::Error<ErrorCode::INVALID_ARGUMENT, false>("convert '{}' as {} failed",  \
1685
3
                                                                     VALUE, #TYPE);                \
1686
3
        }                                                                                          \
1687
18
        TYPE& ref_conf_value = *reinterpret_cast<TYPE*>((FIELD).storage);                          \
1688
15
        TYPE old_value = ref_conf_value;                                                           \
1689
15
        if (RegisterConfValidator::_s_field_validator != nullptr) {                                \
1690
15
            auto validator = RegisterConfValidator::_s_field_validator->find((FIELD).name);        \
1691
15
            if (validator != RegisterConfValidator::_s_field_validator->end() &&                   \
1692
15
                !(validator->second)()) {                                                          \
1693
0
                ref_conf_value = old_value;                                                        \
1694
0
                return Status::Error<ErrorCode::INVALID_ARGUMENT, false>("validate {}={} failed",  \
1695
0
                                                                         (FIELD).name, new_value); \
1696
0
            }                                                                                      \
1697
15
        }                                                                                          \
1698
15
        ref_conf_value = new_value;                                                                \
1699
15
        if (full_conf_map != nullptr) {                                                            \
1700
15
            std::ostringstream oss;                                                                \
1701
15
            oss << new_value;                                                                      \
1702
15
            (*full_conf_map)[(FIELD).name] = oss.str();                                            \
1703
15
        }                                                                                          \
1704
15
        if (PERSIST) {                                                                             \
1705
3
            RETURN_IF_ERROR(persist_config(std::string((FIELD).name), VALUE));                     \
1706
3
        }                                                                                          \
1707
15
        update_config(std::string((FIELD).name), VALUE);                                           \
1708
15
        return Status::OK();                                                                       \
1709
15
    }
1710
1711
// write config to be_custom.conf
1712
// the caller need to make sure that the given config is valid
1713
3
Status persist_config(const std::string& field, const std::string& value) {
1714
    // lock to make sure only one thread can modify the be_custom.conf
1715
3
    std::lock_guard<std::mutex> l(custom_conf_lock);
1716
1717
3
    static const std::string conffile = config::custom_config_dir + "/be_custom.conf";
1718
1719
3
    Properties tmp_props;
1720
3
    if (!tmp_props.load(conffile.c_str(), false)) {
1721
0
        LOG(WARNING) << "failed to load " << conffile;
1722
0
        return Status::InternalError("failed to load conf file: {}", conffile);
1723
0
    }
1724
1725
3
    tmp_props.set_force(field, value);
1726
3
    return tmp_props.dump(conffile);
1727
3
}
1728
1729
Status set_config(const std::string& field, const std::string& value, bool need_persist,
1730
21
                  bool force) {
1731
21
    auto it = Register::_s_field_map->find(field);
1732
21
    if (it == Register::_s_field_map->end()) {
1733
1
        return Status::Error<ErrorCode::NOT_FOUND, false>("'{}' is not found", field);
1734
1
    }
1735
1736
20
    if (!force && !it->second.valmutable) {
1737
2
        return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR, false>(
1738
2
                "'{}' is not support to modify", field);
1739
2
    }
1740
1741
18
    UPDATE_FIELD(it->second, value, bool, need_persist);
1742
12
    UPDATE_FIELD(it->second, value, int16_t, need_persist);
1743
8
    UPDATE_FIELD(it->second, value, int32_t, need_persist);
1744
6
    UPDATE_FIELD(it->second, value, int64_t, need_persist);
1745
5
    UPDATE_FIELD(it->second, value, double, need_persist);
1746
3
    {
1747
        // add lock to ensure thread safe
1748
3
        std::lock_guard<std::mutex> lock(mutable_string_config_lock);
1749
3
        UPDATE_FIELD(it->second, value, std::string, need_persist);
1750
0
    }
1751
1752
    // The other types are not thread safe to change dynamically.
1753
0
    return Status::Error<ErrorCode::NOT_IMPLEMENTED_ERROR, false>(
1754
0
            "'{}' is type of '{}' which is not support to modify", field, it->second.type);
1755
3
}
1756
1757
15
void update_config(const std::string& field, const std::string& value) {
1758
15
    if ("sys_log_level" == field) {
1759
        // update log level
1760
0
        update_logging(field, value);
1761
0
    }
1762
15
}
1763
1764
0
Status set_fuzzy_configs() {
1765
0
    std::unordered_map<std::string, std::string> fuzzy_field_and_value;
1766
0
    std::shared_ptr<std::mt19937_64> generator(new std::mt19937_64());
1767
0
    generator->seed(std::random_device()());
1768
0
    std::uniform_int_distribution<int64_t> distribution(0, 100);
1769
1770
    // if have set enable_fuzzy_mode=true in be.conf, will fuzzy those field and values
1771
0
    fuzzy_field_and_value["disable_storage_page_cache"] =
1772
0
            ((distribution(*generator) % 2) == 0) ? "true" : "false";
1773
0
    fuzzy_field_and_value["enable_system_metrics"] =
1774
0
            ((distribution(*generator) % 2) == 0) ? "true" : "false";
1775
0
    fuzzy_field_and_value["enable_set_in_bitmap_value"] =
1776
0
            ((distribution(*generator) % 2) == 0) ? "true" : "false";
1777
0
    fuzzy_field_and_value["enable_shrink_memory"] =
1778
0
            ((distribution(*generator) % 2) == 0) ? "true" : "false";
1779
1780
0
    fmt::memory_buffer buf;
1781
0
    for (auto& it : fuzzy_field_and_value) {
1782
0
        const auto& field = it.first;
1783
0
        const auto& value = it.second;
1784
0
        RETURN_IF_ERROR(set_config(field, value, false, true));
1785
0
        fmt::format_to(buf, "{}={}, ", field, value);
1786
0
    }
1787
0
    LOG(INFO) << fmt::format("FUZZY MODE IN BE: those variables have been changed: ({}).",
1788
0
                             fmt::to_string(buf));
1789
0
    return Status::OK();
1790
0
}
1791
1792
0
std::mutex* get_mutable_string_config_lock() {
1793
0
    return &mutable_string_config_lock;
1794
0
}
1795
1796
0
std::vector<std::vector<std::string>> get_config_info() {
1797
0
    std::vector<std::vector<std::string>> configs;
1798
0
    std::lock_guard<std::mutex> lock(mutable_string_config_lock);
1799
0
    for (const auto& it : *full_conf_map) {
1800
0
        auto field_it = Register::_s_field_map->find(it.first);
1801
0
        if (field_it == Register::_s_field_map->end()) {
1802
0
            continue;
1803
0
        }
1804
1805
0
        std::vector<std::string> _config;
1806
0
        _config.push_back(it.first);
1807
1808
0
        std::string config_val = it.second;
1809
        // For compatibility, this PR #32933 change the log dir's config logic,
1810
        // and deprecate the `sys_log_dir` config.
1811
0
        if (it.first == "sys_log_dir" && config_val == "") {
1812
0
            config_val = fmt::format("{}/log", std::getenv("DORIS_HOME"));
1813
0
        }
1814
1815
0
        _config.emplace_back(field_it->second.type);
1816
0
        if (0 == strcmp(field_it->second.type, "bool")) {
1817
0
            _config.emplace_back(config_val == "1" ? "true" : "false");
1818
0
        } else {
1819
0
            _config.push_back(config_val);
1820
0
        }
1821
0
        _config.emplace_back(field_it->second.valmutable ? "true" : "false");
1822
1823
0
        configs.push_back(_config);
1824
0
    }
1825
0
    return configs;
1826
0
}
1827
1828
} // namespace doris::config