Coverage Report

Created: 2026-11-12 08:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rocksdb/options/db_options.h
Line
Count
Source
1
// Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under both the GPLv2 (found in the
3
//  COPYING file in the root directory) and Apache 2.0 License
4
//  (found in the LICENSE.Apache file in the root directory).
5
6
#pragma once
7
8
#include <string>
9
#include <vector>
10
11
#include "rocksdb/options.h"
12
13
namespace ROCKSDB_NAMESPACE {
14
class SystemClock;
15
16
struct ImmutableDBOptions {
17
381k
  static const char* kName() { return "ImmutableDBOptions"; }
18
  ImmutableDBOptions();
19
  explicit ImmutableDBOptions(const DBOptions& options);
20
21
  void Dump(Logger* log) const;
22
23
  bool create_if_missing;
24
  bool create_missing_column_families;
25
  bool error_if_exists;
26
  bool paranoid_checks;
27
  bool open_files_async;
28
  bool flush_verify_memtable_count;
29
  bool compaction_verify_record_count;
30
  bool track_and_verify_wals_in_manifest;
31
  bool track_and_verify_wals;
32
  bool verify_sst_unique_id_in_manifest;
33
  Env* env;
34
  std::shared_ptr<RateLimiter> rate_limiter;
35
  std::shared_ptr<SstFileManager> sst_file_manager;
36
  std::shared_ptr<Logger> info_log;
37
  InfoLogLevel info_log_level;
38
  int max_file_opening_threads;
39
  int read_io_executor_threads;
40
  std::shared_ptr<Statistics> statistics;
41
  bool use_fsync;
42
  std::vector<DbPath> db_paths;
43
  std::string db_log_dir;
44
  // The wal_dir option from the file.  To determine the
45
  // directory in use, the GetWalDir or IsWalDirSameAsDBPath
46
  // methods should be used instead of accessing this variable directly.
47
  std::string wal_dir;
48
  size_t max_log_file_size;
49
  size_t log_file_time_to_roll;
50
  size_t keep_log_file_num;
51
  size_t recycle_log_file_num;
52
  // Immutable copy of DBOptions::async_wal_precreate.
53
  bool async_wal_precreate;
54
  int table_cache_numshardbits;
55
  uint64_t WAL_ttl_seconds;
56
  uint64_t WAL_size_limit_MB;
57
  uint64_t max_write_batch_group_size_bytes;
58
  bool allow_mmap_reads;
59
  bool allow_mmap_writes;
60
  bool use_direct_reads;
61
  bool use_direct_io_for_compaction_reads;
62
  bool use_direct_io_for_flush_and_compaction;
63
  bool allow_fallocate;
64
  bool is_fd_close_on_exec;
65
  bool advise_random_on_open;
66
  size_t db_write_buffer_size;
67
  std::shared_ptr<WriteBufferManager> write_buffer_manager;
68
  bool use_adaptive_mutex;
69
  std::vector<std::shared_ptr<EventListener>> listeners;
70
  bool enable_thread_tracking;
71
  bool enable_pipelined_write;
72
  bool unordered_write;
73
  bool allow_concurrent_memtable_write;
74
  bool enable_write_thread_adaptive_yield;
75
  uint64_t write_thread_max_yield_usec;
76
  uint64_t write_thread_slow_yield_usec;
77
  bool skip_stats_update_on_db_open;
78
  WALRecoveryMode wal_recovery_mode;
79
  bool allow_2pc;
80
  std::shared_ptr<Cache> row_cache;
81
  WalFilter* wal_filter;
82
  bool dump_malloc_stats;
83
  bool avoid_flush_during_recovery;
84
  bool enforce_write_buffer_manager_during_recovery;
85
  bool allow_ingest_behind;
86
  bool two_write_queues;
87
  bool manual_wal_flush;
88
  CompressionType wal_compression;
89
  bool background_close_inactive_wals;
90
  bool atomic_flush;
91
  bool avoid_unnecessary_blocking_io;
92
  bool prefix_seek_opt_in_only;
93
  bool persist_stats_to_disk;
94
  bool write_dbid_to_manifest;
95
  bool track_options_file_number_in_manifest;
96
  bool reuse_manifest_on_open;
97
  bool write_identity_file;
98
  size_t log_readahead_size;
99
  std::shared_ptr<FileChecksumGenFactory> file_checksum_gen_factory;
100
  bool best_efforts_recovery;
101
  bool best_efforts_blob_db_repair;
102
  int max_bgerror_resume_count;
103
  uint64_t bgerror_resume_retry_interval;
104
  bool allow_data_in_errors;
105
  std::string db_host_id;
106
  FileTypeSet checksum_handoff_file_types;
107
  CacheTier lowest_used_cache_tier;
108
  std::shared_ptr<CompactionService> compaction_service;
109
  bool use_session_tmp_dir_for_remote_compaction;
110
  bool enforce_single_del_contracts;
111
  uint64_t follower_refresh_catchup_period_ms;
112
  uint64_t follower_catchup_retry_count;
113
  uint64_t follower_catchup_retry_wait_ms;
114
  Temperature metadata_write_temperature;
115
  Temperature wal_write_temperature;
116
  CompactionStyleSet calculate_sst_write_lifetime_hint_set;
117
118
  // Beginning convenience/helper objects that are not part of the base
119
  // DBOptions
120
  std::shared_ptr<FileSystem> fs;
121
  SystemClock* clock;
122
  Statistics* stats;
123
  Logger* logger;
124
  // End of convenience/helper objects.
125
126
  bool IsWalDirSameAsDBPath() const;
127
  bool IsWalDirSameAsDBPath(const std::string& path) const;
128
  // Whether DB open recovers through VersionSet::TryRecover(), which both
129
  // best_efforts_recovery and best_efforts_blob_db_repair use.
130
134k
  bool UsesBestEffortsRecoveryPath() const {
131
134k
    return best_efforts_recovery || best_efforts_blob_db_repair;
132
134k
  }
133
  const std::string& GetWalDir() const;
134
  const std::string& GetWalDir(const std::string& path) const;
135
};
136
137
struct MutableDBOptions {
138
381k
  static const char* kName() { return "MutableDBOptions"; }
139
  MutableDBOptions();
140
  explicit MutableDBOptions(const DBOptions& options);
141
142
  void Dump(Logger* log) const;
143
144
  size_t writable_file_max_buffer_size;
145
  uint64_t delayed_write_rate;
146
  uint64_t max_total_wal_size;
147
  uint64_t delete_obsolete_files_period_micros;
148
  uint64_t mutex_hold_log_threshold_us;
149
  size_t stats_history_buffer_size;
150
  uint64_t bytes_per_sync;
151
  uint64_t wal_bytes_per_sync;
152
  size_t compaction_readahead_size;
153
  uint64_t max_manifest_file_size;
154
  size_t manifest_preallocation_size;
155
  uint64_t max_compaction_trigger_wakeup_seconds;
156
  std::string daily_offpeak_time_utc;
157
  int max_background_jobs;
158
  int max_background_compactions;
159
  uint32_t max_subcompactions;
160
  unsigned int stats_dump_period_sec;
161
  unsigned int stats_persist_period_sec;
162
  int max_open_files;
163
  int max_background_flushes;
164
  int max_manifest_space_amp_pct;
165
  int periodic_compaction_phase_recovery_percent;
166
  bool avoid_flush_during_shutdown;
167
  bool strict_bytes_per_sync;
168
  bool verify_manifest_content_on_close;
169
  bool optimize_manifest_for_recovery;
170
  bool fast_sst_open;
171
  bool remote_compaction_manifest_floor;
172
  bool use_separate_remote_compaction_pool;
173
};
174
175
Status GetStringFromMutableDBOptions(const ConfigOptions& config_options,
176
                                     const MutableDBOptions& mutable_opts,
177
                                     std::string* opt_string);
178
179
Status GetMutableDBOptionsFromStrings(
180
    const MutableDBOptions& base_options,
181
    const std::unordered_map<std::string, std::string>& options_map,
182
    MutableDBOptions* new_options);
183
184
bool MutableDBOptionsAreEqual(const MutableDBOptions& this_options,
185
                              const MutableDBOptions& that_options);
186
187
}  // namespace ROCKSDB_NAMESPACE