Coverage Report

Created: 2024-07-27 06:53

/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
123k
  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 flush_verify_memtable_count;
28
  bool compaction_verify_record_count;
29
  bool track_and_verify_wals_in_manifest;
30
  bool verify_sst_unique_id_in_manifest;
31
  Env* env;
32
  std::shared_ptr<RateLimiter> rate_limiter;
33
  std::shared_ptr<SstFileManager> sst_file_manager;
34
  std::shared_ptr<Logger> info_log;
35
  InfoLogLevel info_log_level;
36
  int max_file_opening_threads;
37
  std::shared_ptr<Statistics> statistics;
38
  bool use_fsync;
39
  std::vector<DbPath> db_paths;
40
  std::string db_log_dir;
41
  // The wal_dir option from the file.  To determine the
42
  // directory in use, the GetWalDir or IsWalDirSameAsDBPath
43
  // methods should be used instead of accessing this variable directly.
44
  std::string wal_dir;
45
  size_t max_log_file_size;
46
  size_t log_file_time_to_roll;
47
  size_t keep_log_file_num;
48
  size_t recycle_log_file_num;
49
  uint64_t max_manifest_file_size;
50
  int table_cache_numshardbits;
51
  uint64_t WAL_ttl_seconds;
52
  uint64_t WAL_size_limit_MB;
53
  uint64_t max_write_batch_group_size_bytes;
54
  size_t manifest_preallocation_size;
55
  bool allow_mmap_reads;
56
  bool allow_mmap_writes;
57
  bool use_direct_reads;
58
  bool use_direct_io_for_flush_and_compaction;
59
  bool allow_fallocate;
60
  bool is_fd_close_on_exec;
61
  bool advise_random_on_open;
62
  size_t db_write_buffer_size;
63
  std::shared_ptr<WriteBufferManager> write_buffer_manager;
64
  size_t random_access_max_buffer_size;
65
  bool use_adaptive_mutex;
66
  std::vector<std::shared_ptr<EventListener>> listeners;
67
  bool enable_thread_tracking;
68
  bool enable_pipelined_write;
69
  bool unordered_write;
70
  bool allow_concurrent_memtable_write;
71
  bool enable_write_thread_adaptive_yield;
72
  uint64_t write_thread_max_yield_usec;
73
  uint64_t write_thread_slow_yield_usec;
74
  bool skip_stats_update_on_db_open;
75
  bool skip_checking_sst_file_sizes_on_db_open;
76
  WALRecoveryMode wal_recovery_mode;
77
  bool allow_2pc;
78
  std::shared_ptr<Cache> row_cache;
79
  WalFilter* wal_filter;
80
  bool fail_if_options_file_error;
81
  bool dump_malloc_stats;
82
  bool avoid_flush_during_recovery;
83
  bool allow_ingest_behind;
84
  bool two_write_queues;
85
  bool manual_wal_flush;
86
  CompressionType wal_compression;
87
  bool background_close_inactive_wals;
88
  bool atomic_flush;
89
  bool avoid_unnecessary_blocking_io;
90
  bool persist_stats_to_disk;
91
  bool write_dbid_to_manifest;
92
  size_t log_readahead_size;
93
  std::shared_ptr<FileChecksumGenFactory> file_checksum_gen_factory;
94
  bool best_efforts_recovery;
95
  int max_bgerror_resume_count;
96
  uint64_t bgerror_resume_retry_interval;
97
  bool allow_data_in_errors;
98
  std::string db_host_id;
99
  FileTypeSet checksum_handoff_file_types;
100
  CacheTier lowest_used_cache_tier;
101
  std::shared_ptr<CompactionService> compaction_service;
102
  bool enforce_single_del_contracts;
103
  uint64_t follower_refresh_catchup_period_ms;
104
  uint64_t follower_catchup_retry_count;
105
  uint64_t follower_catchup_retry_wait_ms;
106
107
  // Beginning convenience/helper objects that are not part of the base
108
  // DBOptions
109
  std::shared_ptr<FileSystem> fs;
110
  SystemClock* clock;
111
  Statistics* stats;
112
  Logger* logger;
113
  // End of convenience/helper objects.
114
115
  bool IsWalDirSameAsDBPath() const;
116
  bool IsWalDirSameAsDBPath(const std::string& path) const;
117
  const std::string& GetWalDir() const;
118
  const std::string& GetWalDir(const std::string& path) const;
119
};
120
121
struct MutableDBOptions {
122
123k
  static const char* kName() { return "MutableDBOptions"; }
123
  MutableDBOptions();
124
  explicit MutableDBOptions(const DBOptions& options);
125
126
  void Dump(Logger* log) const;
127
128
  int max_background_jobs;
129
  int max_background_compactions;
130
  uint32_t max_subcompactions;
131
  bool avoid_flush_during_shutdown;
132
  size_t writable_file_max_buffer_size;
133
  uint64_t delayed_write_rate;
134
  uint64_t max_total_wal_size;
135
  uint64_t delete_obsolete_files_period_micros;
136
  unsigned int stats_dump_period_sec;
137
  unsigned int stats_persist_period_sec;
138
  size_t stats_history_buffer_size;
139
  int max_open_files;
140
  uint64_t bytes_per_sync;
141
  uint64_t wal_bytes_per_sync;
142
  bool strict_bytes_per_sync;
143
  size_t compaction_readahead_size;
144
  int max_background_flushes;
145
  std::string daily_offpeak_time_utc;
146
};
147
148
Status GetStringFromMutableDBOptions(const ConfigOptions& config_options,
149
                                     const MutableDBOptions& mutable_opts,
150
                                     std::string* opt_string);
151
152
Status GetMutableDBOptionsFromStrings(
153
    const MutableDBOptions& base_options,
154
    const std::unordered_map<std::string, std::string>& options_map,
155
    MutableDBOptions* new_options);
156
157
bool MutableDBOptionsAreEqual(const MutableDBOptions& this_options,
158
                              const MutableDBOptions& that_options);
159
160
}  // namespace ROCKSDB_NAMESPACE