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).
6 #include "options/db_options.h"
10 #include "logging/logging.h"
11 #include "options/configurable_helper.h"
12 #include "options/options_helper.h"
13 #include "options/options_parser.h"
14 #include "port/port.h"
15 #include "rocksdb/configurable.h"
16 #include "rocksdb/env.h"
17 #include "rocksdb/file_system.h"
18 #include "rocksdb/listener.h"
19 #include "rocksdb/rate_limiter.h"
20 #include "rocksdb/sst_file_manager.h"
21 #include "rocksdb/statistics.h"
22 #include "rocksdb/system_clock.h"
23 #include "rocksdb/utilities/options_type.h"
24 #include "rocksdb/wal_filter.h"
25 #include "util/string_util.h"
27 namespace ROCKSDB_NAMESPACE
{
29 static std::unordered_map
<std::string
, WALRecoveryMode
>
30 wal_recovery_mode_string_map
= {
31 {"kTolerateCorruptedTailRecords",
32 WALRecoveryMode::kTolerateCorruptedTailRecords
},
33 {"kAbsoluteConsistency", WALRecoveryMode::kAbsoluteConsistency
},
34 {"kPointInTimeRecovery", WALRecoveryMode::kPointInTimeRecovery
},
35 {"kSkipAnyCorruptedRecords",
36 WALRecoveryMode::kSkipAnyCorruptedRecords
}};
38 static std::unordered_map
<std::string
, DBOptions::AccessHint
>
39 access_hint_string_map
= {{"NONE", DBOptions::AccessHint::NONE
},
40 {"NORMAL", DBOptions::AccessHint::NORMAL
},
41 {"SEQUENTIAL", DBOptions::AccessHint::SEQUENTIAL
},
42 {"WILLNEED", DBOptions::AccessHint::WILLNEED
}};
44 static std::unordered_map
<std::string
, CacheTier
> cache_tier_string_map
= {
45 {"kVolatileTier", CacheTier::kVolatileTier
},
46 {"kNonVolatileBlockTier", CacheTier::kNonVolatileBlockTier
}};
48 static std::unordered_map
<std::string
, InfoLogLevel
> info_log_level_string_map
=
49 {{"DEBUG_LEVEL", InfoLogLevel::DEBUG_LEVEL
},
50 {"INFO_LEVEL", InfoLogLevel::INFO_LEVEL
},
51 {"WARN_LEVEL", InfoLogLevel::WARN_LEVEL
},
52 {"ERROR_LEVEL", InfoLogLevel::ERROR_LEVEL
},
53 {"FATAL_LEVEL", InfoLogLevel::FATAL_LEVEL
},
54 {"HEADER_LEVEL", InfoLogLevel::HEADER_LEVEL
}};
56 static std::unordered_map
<std::string
, OptionTypeInfo
>
57 db_mutable_options_type_info
= {
59 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
60 OptionTypeFlags::kMutable
}},
61 {"base_background_compactions",
62 {0, OptionType::kInt
, OptionVerificationType::kDeprecated
,
63 OptionTypeFlags::kMutable
}},
64 {"max_background_jobs",
65 {offsetof(struct MutableDBOptions
, max_background_jobs
),
66 OptionType::kInt
, OptionVerificationType::kNormal
,
67 OptionTypeFlags::kMutable
}},
68 {"max_background_compactions",
69 {offsetof(struct MutableDBOptions
, max_background_compactions
),
70 OptionType::kInt
, OptionVerificationType::kNormal
,
71 OptionTypeFlags::kMutable
}},
72 {"max_subcompactions",
73 {offsetof(struct MutableDBOptions
, max_subcompactions
),
74 OptionType::kUInt32T
, OptionVerificationType::kNormal
,
75 OptionTypeFlags::kMutable
}},
76 {"avoid_flush_during_shutdown",
77 {offsetof(struct MutableDBOptions
, avoid_flush_during_shutdown
),
78 OptionType::kBoolean
, OptionVerificationType::kNormal
,
79 OptionTypeFlags::kMutable
}},
80 {"writable_file_max_buffer_size",
81 {offsetof(struct MutableDBOptions
, writable_file_max_buffer_size
),
82 OptionType::kSizeT
, OptionVerificationType::kNormal
,
83 OptionTypeFlags::kMutable
}},
84 {"delayed_write_rate",
85 {offsetof(struct MutableDBOptions
, delayed_write_rate
),
86 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
87 OptionTypeFlags::kMutable
}},
88 {"max_total_wal_size",
89 {offsetof(struct MutableDBOptions
, max_total_wal_size
),
90 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
91 OptionTypeFlags::kMutable
}},
92 {"delete_obsolete_files_period_micros",
93 {offsetof(struct MutableDBOptions
,
94 delete_obsolete_files_period_micros
),
95 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
96 OptionTypeFlags::kMutable
}},
97 {"stats_dump_period_sec",
98 {offsetof(struct MutableDBOptions
, stats_dump_period_sec
),
99 OptionType::kUInt
, OptionVerificationType::kNormal
,
100 OptionTypeFlags::kMutable
}},
101 {"stats_persist_period_sec",
102 {offsetof(struct MutableDBOptions
, stats_persist_period_sec
),
103 OptionType::kUInt
, OptionVerificationType::kNormal
,
104 OptionTypeFlags::kMutable
}},
105 {"stats_history_buffer_size",
106 {offsetof(struct MutableDBOptions
, stats_history_buffer_size
),
107 OptionType::kSizeT
, OptionVerificationType::kNormal
,
108 OptionTypeFlags::kMutable
}},
110 {offsetof(struct MutableDBOptions
, max_open_files
), OptionType::kInt
,
111 OptionVerificationType::kNormal
, OptionTypeFlags::kMutable
}},
113 {offsetof(struct MutableDBOptions
, bytes_per_sync
),
114 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
115 OptionTypeFlags::kMutable
}},
116 {"wal_bytes_per_sync",
117 {offsetof(struct MutableDBOptions
, wal_bytes_per_sync
),
118 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
119 OptionTypeFlags::kMutable
}},
120 {"strict_bytes_per_sync",
121 {offsetof(struct MutableDBOptions
, strict_bytes_per_sync
),
122 OptionType::kBoolean
, OptionVerificationType::kNormal
,
123 OptionTypeFlags::kMutable
}},
124 {"compaction_readahead_size",
125 {offsetof(struct MutableDBOptions
, compaction_readahead_size
),
126 OptionType::kSizeT
, OptionVerificationType::kNormal
,
127 OptionTypeFlags::kMutable
}},
128 {"max_background_flushes",
129 {offsetof(struct MutableDBOptions
, max_background_flushes
),
130 OptionType::kInt
, OptionVerificationType::kNormal
,
131 OptionTypeFlags::kMutable
}},
134 static std::unordered_map
<std::string
, OptionTypeInfo
>
135 db_immutable_options_type_info
= {
138 std::shared_ptr<Cache> row_cache;
139 std::shared_ptr<DeleteScheduler> delete_scheduler;
140 std::shared_ptr<Logger> info_log;
141 std::shared_ptr<RateLimiter> rate_limiter;
142 std::shared_ptr<Statistics> statistics;
143 std::vector<DbPath> db_paths;
144 FileTypeSet checksum_handoff_file_types;
146 {"advise_random_on_open",
147 {offsetof(struct ImmutableDBOptions
, advise_random_on_open
),
148 OptionType::kBoolean
, OptionVerificationType::kNormal
,
149 OptionTypeFlags::kNone
}},
151 {offsetof(struct ImmutableDBOptions
, allow_mmap_reads
),
152 OptionType::kBoolean
, OptionVerificationType::kNormal
,
153 OptionTypeFlags::kNone
}},
155 {offsetof(struct ImmutableDBOptions
, allow_fallocate
),
156 OptionType::kBoolean
, OptionVerificationType::kNormal
,
157 OptionTypeFlags::kNone
}},
158 {"allow_mmap_writes",
159 {offsetof(struct ImmutableDBOptions
, allow_mmap_writes
),
160 OptionType::kBoolean
, OptionVerificationType::kNormal
,
161 OptionTypeFlags::kNone
}},
163 {offsetof(struct ImmutableDBOptions
, use_direct_reads
),
164 OptionType::kBoolean
, OptionVerificationType::kNormal
,
165 OptionTypeFlags::kNone
}},
166 {"use_direct_writes",
167 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
168 OptionTypeFlags::kNone
}},
169 {"use_direct_io_for_flush_and_compaction",
170 {offsetof(struct ImmutableDBOptions
,
171 use_direct_io_for_flush_and_compaction
),
172 OptionType::kBoolean
, OptionVerificationType::kNormal
,
173 OptionTypeFlags::kNone
}},
175 {offsetof(struct ImmutableDBOptions
, allow_2pc
), OptionType::kBoolean
,
176 OptionVerificationType::kNormal
, OptionTypeFlags::kNone
}},
178 OptionTypeInfo::AsCustomRawPtr
<WalFilter
>(
179 offsetof(struct ImmutableDBOptions
, wal_filter
),
180 OptionVerificationType::kByName
,
181 (OptionTypeFlags::kAllowNull
| OptionTypeFlags::kCompareNever
))},
182 {"create_if_missing",
183 {offsetof(struct ImmutableDBOptions
, create_if_missing
),
184 OptionType::kBoolean
, OptionVerificationType::kNormal
,
185 OptionTypeFlags::kNone
}},
186 {"create_missing_column_families",
187 {offsetof(struct ImmutableDBOptions
, create_missing_column_families
),
188 OptionType::kBoolean
, OptionVerificationType::kNormal
,
189 OptionTypeFlags::kNone
}},
191 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
192 OptionTypeFlags::kNone
}},
193 {"disable_data_sync", // for compatibility
194 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
195 OptionTypeFlags::kNone
}},
196 {"enable_thread_tracking",
197 {offsetof(struct ImmutableDBOptions
, enable_thread_tracking
),
198 OptionType::kBoolean
, OptionVerificationType::kNormal
,
199 OptionTypeFlags::kNone
}},
201 {offsetof(struct ImmutableDBOptions
, error_if_exists
),
202 OptionType::kBoolean
, OptionVerificationType::kNormal
,
203 OptionTypeFlags::kNone
}},
204 {"experimental_allow_mempurge",
205 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
206 OptionTypeFlags::kNone
}},
207 {"experimental_mempurge_policy",
208 {0, OptionType::kString
, OptionVerificationType::kDeprecated
,
209 OptionTypeFlags::kNone
}},
210 {"experimental_mempurge_threshold",
211 {0, OptionType::kDouble
, OptionVerificationType::kDeprecated
,
212 OptionTypeFlags::kNone
}},
213 {"is_fd_close_on_exec",
214 {offsetof(struct ImmutableDBOptions
, is_fd_close_on_exec
),
215 OptionType::kBoolean
, OptionVerificationType::kNormal
,
216 OptionTypeFlags::kNone
}},
218 {offsetof(struct ImmutableDBOptions
, paranoid_checks
),
219 OptionType::kBoolean
, OptionVerificationType::kNormal
,
220 OptionTypeFlags::kNone
}},
221 {"flush_verify_memtable_count",
222 {offsetof(struct ImmutableDBOptions
, flush_verify_memtable_count
),
223 OptionType::kBoolean
, OptionVerificationType::kNormal
,
224 OptionTypeFlags::kNone
}},
225 {"track_and_verify_wals_in_manifest",
226 {offsetof(struct ImmutableDBOptions
,
227 track_and_verify_wals_in_manifest
),
228 OptionType::kBoolean
, OptionVerificationType::kNormal
,
229 OptionTypeFlags::kNone
}},
230 {"verify_sst_unique_id_in_manifest",
231 {offsetof(struct ImmutableDBOptions
, verify_sst_unique_id_in_manifest
),
232 OptionType::kBoolean
, OptionVerificationType::kNormal
,
233 OptionTypeFlags::kNone
}},
234 {"skip_log_error_on_recovery",
235 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
236 OptionTypeFlags::kNone
}},
237 {"skip_stats_update_on_db_open",
238 {offsetof(struct ImmutableDBOptions
, skip_stats_update_on_db_open
),
239 OptionType::kBoolean
, OptionVerificationType::kNormal
,
240 OptionTypeFlags::kNone
}},
241 {"skip_checking_sst_file_sizes_on_db_open",
242 {offsetof(struct ImmutableDBOptions
,
243 skip_checking_sst_file_sizes_on_db_open
),
244 OptionType::kBoolean
, OptionVerificationType::kNormal
,
245 OptionTypeFlags::kNone
}},
246 {"new_table_reader_for_compaction_inputs",
247 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
248 OptionTypeFlags::kNone
}},
249 {"random_access_max_buffer_size",
250 {offsetof(struct ImmutableDBOptions
, random_access_max_buffer_size
),
251 OptionType::kSizeT
, OptionVerificationType::kNormal
,
252 OptionTypeFlags::kNone
}},
253 {"use_adaptive_mutex",
254 {offsetof(struct ImmutableDBOptions
, use_adaptive_mutex
),
255 OptionType::kBoolean
, OptionVerificationType::kNormal
,
256 OptionTypeFlags::kNone
}},
258 {offsetof(struct ImmutableDBOptions
, use_fsync
), OptionType::kBoolean
,
259 OptionVerificationType::kNormal
, OptionTypeFlags::kNone
}},
260 {"max_file_opening_threads",
261 {offsetof(struct ImmutableDBOptions
, max_file_opening_threads
),
262 OptionType::kInt
, OptionVerificationType::kNormal
,
263 OptionTypeFlags::kNone
}},
264 {"table_cache_numshardbits",
265 {offsetof(struct ImmutableDBOptions
, table_cache_numshardbits
),
266 OptionType::kInt
, OptionVerificationType::kNormal
,
267 OptionTypeFlags::kNone
}},
268 {"db_write_buffer_size",
269 {offsetof(struct ImmutableDBOptions
, db_write_buffer_size
),
270 OptionType::kSizeT
, OptionVerificationType::kNormal
,
271 OptionTypeFlags::kNone
}},
272 {"keep_log_file_num",
273 {offsetof(struct ImmutableDBOptions
, keep_log_file_num
),
274 OptionType::kSizeT
, OptionVerificationType::kNormal
,
275 OptionTypeFlags::kNone
}},
276 {"recycle_log_file_num",
277 {offsetof(struct ImmutableDBOptions
, recycle_log_file_num
),
278 OptionType::kSizeT
, OptionVerificationType::kNormal
,
279 OptionTypeFlags::kNone
}},
280 {"log_file_time_to_roll",
281 {offsetof(struct ImmutableDBOptions
, log_file_time_to_roll
),
282 OptionType::kSizeT
, OptionVerificationType::kNormal
,
283 OptionTypeFlags::kNone
}},
284 {"manifest_preallocation_size",
285 {offsetof(struct ImmutableDBOptions
, manifest_preallocation_size
),
286 OptionType::kSizeT
, OptionVerificationType::kNormal
,
287 OptionTypeFlags::kNone
}},
288 {"max_log_file_size",
289 {offsetof(struct ImmutableDBOptions
, max_log_file_size
),
290 OptionType::kSizeT
, OptionVerificationType::kNormal
,
291 OptionTypeFlags::kNone
}},
293 {offsetof(struct ImmutableDBOptions
, db_log_dir
), OptionType::kString
,
294 OptionVerificationType::kNormal
, OptionTypeFlags::kNone
}},
296 {offsetof(struct ImmutableDBOptions
, wal_dir
), OptionType::kString
,
297 OptionVerificationType::kNormal
, OptionTypeFlags::kNone
}},
298 {"WAL_size_limit_MB",
299 {offsetof(struct ImmutableDBOptions
, WAL_size_limit_MB
),
300 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
301 OptionTypeFlags::kNone
}},
303 {offsetof(struct ImmutableDBOptions
, WAL_ttl_seconds
),
304 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
305 OptionTypeFlags::kNone
}},
306 {"max_manifest_file_size",
307 {offsetof(struct ImmutableDBOptions
, max_manifest_file_size
),
308 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
309 OptionTypeFlags::kNone
}},
310 {"persist_stats_to_disk",
311 {offsetof(struct ImmutableDBOptions
, persist_stats_to_disk
),
312 OptionType::kBoolean
, OptionVerificationType::kNormal
,
313 OptionTypeFlags::kNone
}},
314 {"fail_if_options_file_error",
315 {offsetof(struct ImmutableDBOptions
, fail_if_options_file_error
),
316 OptionType::kBoolean
, OptionVerificationType::kNormal
,
317 OptionTypeFlags::kNone
}},
318 {"enable_pipelined_write",
319 {offsetof(struct ImmutableDBOptions
, enable_pipelined_write
),
320 OptionType::kBoolean
, OptionVerificationType::kNormal
,
321 OptionTypeFlags::kNone
}},
323 {offsetof(struct ImmutableDBOptions
, unordered_write
),
324 OptionType::kBoolean
, OptionVerificationType::kNormal
,
325 OptionTypeFlags::kNone
}},
326 {"allow_concurrent_memtable_write",
327 {offsetof(struct ImmutableDBOptions
, allow_concurrent_memtable_write
),
328 OptionType::kBoolean
, OptionVerificationType::kNormal
,
329 OptionTypeFlags::kNone
}},
330 {"wal_recovery_mode",
331 OptionTypeInfo::Enum
<WALRecoveryMode
>(
332 offsetof(struct ImmutableDBOptions
, wal_recovery_mode
),
333 &wal_recovery_mode_string_map
)},
334 {"enable_write_thread_adaptive_yield",
335 {offsetof(struct ImmutableDBOptions
,
336 enable_write_thread_adaptive_yield
),
337 OptionType::kBoolean
, OptionVerificationType::kNormal
,
338 OptionTypeFlags::kNone
}},
339 {"write_thread_slow_yield_usec",
340 {offsetof(struct ImmutableDBOptions
, write_thread_slow_yield_usec
),
341 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
342 OptionTypeFlags::kNone
}},
343 {"max_write_batch_group_size_bytes",
344 {offsetof(struct ImmutableDBOptions
, max_write_batch_group_size_bytes
),
345 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
346 OptionTypeFlags::kNone
}},
347 {"write_thread_max_yield_usec",
348 {offsetof(struct ImmutableDBOptions
, write_thread_max_yield_usec
),
349 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
350 OptionTypeFlags::kNone
}},
351 {"access_hint_on_compaction_start",
352 OptionTypeInfo::Enum
<DBOptions::AccessHint
>(
353 offsetof(struct ImmutableDBOptions
,
354 access_hint_on_compaction_start
),
355 &access_hint_string_map
)},
357 OptionTypeInfo::Enum
<InfoLogLevel
>(
358 offsetof(struct ImmutableDBOptions
, info_log_level
),
359 &info_log_level_string_map
)},
360 {"dump_malloc_stats",
361 {offsetof(struct ImmutableDBOptions
, dump_malloc_stats
),
362 OptionType::kBoolean
, OptionVerificationType::kNormal
,
363 OptionTypeFlags::kNone
}},
364 {"avoid_flush_during_recovery",
365 {offsetof(struct ImmutableDBOptions
, avoid_flush_during_recovery
),
366 OptionType::kBoolean
, OptionVerificationType::kNormal
,
367 OptionTypeFlags::kNone
}},
368 {"allow_ingest_behind",
369 {offsetof(struct ImmutableDBOptions
, allow_ingest_behind
),
370 OptionType::kBoolean
, OptionVerificationType::kNormal
,
371 OptionTypeFlags::kNone
}},
373 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
374 OptionTypeFlags::kNone
}},
375 {"concurrent_prepare", // Deprecated by two_write_queues
376 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
377 OptionTypeFlags::kNone
}},
379 {offsetof(struct ImmutableDBOptions
, two_write_queues
),
380 OptionType::kBoolean
, OptionVerificationType::kNormal
,
381 OptionTypeFlags::kNone
}},
383 {offsetof(struct ImmutableDBOptions
, manual_wal_flush
),
384 OptionType::kBoolean
, OptionVerificationType::kNormal
,
385 OptionTypeFlags::kNone
}},
387 {offsetof(struct ImmutableDBOptions
, wal_compression
),
388 OptionType::kCompressionType
, OptionVerificationType::kNormal
,
389 OptionTypeFlags::kNone
}},
391 {0, OptionType::kBoolean
, OptionVerificationType::kDeprecated
,
392 OptionTypeFlags::kNone
}},
394 {offsetof(struct ImmutableDBOptions
, atomic_flush
),
395 OptionType::kBoolean
, OptionVerificationType::kNormal
,
396 OptionTypeFlags::kNone
}},
397 {"avoid_unnecessary_blocking_io",
398 {offsetof(struct ImmutableDBOptions
, avoid_unnecessary_blocking_io
),
399 OptionType::kBoolean
, OptionVerificationType::kNormal
,
400 OptionTypeFlags::kNone
}},
401 {"write_dbid_to_manifest",
402 {offsetof(struct ImmutableDBOptions
, write_dbid_to_manifest
),
403 OptionType::kBoolean
, OptionVerificationType::kNormal
,
404 OptionTypeFlags::kNone
}},
405 {"log_readahead_size",
406 {offsetof(struct ImmutableDBOptions
, log_readahead_size
),
407 OptionType::kSizeT
, OptionVerificationType::kNormal
,
408 OptionTypeFlags::kNone
}},
409 {"best_efforts_recovery",
410 {offsetof(struct ImmutableDBOptions
, best_efforts_recovery
),
411 OptionType::kBoolean
, OptionVerificationType::kNormal
,
412 OptionTypeFlags::kNone
}},
413 {"max_bgerror_resume_count",
414 {offsetof(struct ImmutableDBOptions
, max_bgerror_resume_count
),
415 OptionType::kInt
, OptionVerificationType::kNormal
,
416 OptionTypeFlags::kNone
}},
417 {"bgerror_resume_retry_interval",
418 {offsetof(struct ImmutableDBOptions
, bgerror_resume_retry_interval
),
419 OptionType::kUInt64T
, OptionVerificationType::kNormal
,
420 OptionTypeFlags::kNone
}},
422 {offsetof(struct ImmutableDBOptions
, db_host_id
), OptionType::kString
,
423 OptionVerificationType::kNormal
, OptionTypeFlags::kCompareNever
}},
424 // Temporarily deprecated due to race conditions (examples in PR 10375).
426 {offsetof(struct ImmutableDBOptions
, rate_limiter
),
427 OptionType::kUnknown
, OptionVerificationType::kDeprecated
,
428 OptionTypeFlags::kDontSerialize
| OptionTypeFlags::kCompareNever
}},
429 // The following properties were handled as special cases in ParseOption
430 // This means that the properties could be read from the options file
431 // but never written to the file or compared to each other.
432 {"rate_limiter_bytes_per_sec",
433 {offsetof(struct ImmutableDBOptions
, rate_limiter
),
434 OptionType::kUnknown
, OptionVerificationType::kNormal
,
435 (OptionTypeFlags::kDontSerialize
| OptionTypeFlags::kCompareNever
),
436 // Parse the input value as a RateLimiter
437 [](const ConfigOptions
& /*opts*/, const std::string
& /*name*/,
438 const std::string
& value
, void* addr
) {
439 auto limiter
= static_cast<std::shared_ptr
<RateLimiter
>*>(addr
);
440 limiter
->reset(NewGenericRateLimiter(
441 static_cast<int64_t>(ParseUint64(value
))));
444 {"env", //**TODO: Should this be kCustomizable?
446 offsetof(struct ImmutableDBOptions
, env
), OptionType::kUnknown
,
447 OptionVerificationType::kNormal
,
448 (OptionTypeFlags::kDontSerialize
| OptionTypeFlags::kCompareNever
))
449 .SetParseFunc([](const ConfigOptions
& opts
,
450 const std::string
& /*name*/,
451 const std::string
& value
, void* addr
) {
452 // Parse the input value as an Env
453 auto old_env
= static_cast<Env
**>(addr
); // Get the old value
454 Env
* new_env
= *old_env
; // Set new to old
455 Status s
= Env::CreateFromString(opts
, value
,
456 &new_env
); // Update new value
457 if (s
.ok()) { // It worked
458 *old_env
= new_env
; // Update the old one
462 .SetPrepareFunc([](const ConfigOptions
& opts
,
463 const std::string
& /*name*/, void* addr
) {
464 auto env
= static_cast<Env
**>(addr
);
465 return (*env
)->PrepareOptions(opts
);
467 .SetValidateFunc([](const DBOptions
& db_opts
,
468 const ColumnFamilyOptions
& cf_opts
,
469 const std::string
& /*name*/,
471 const auto env
= static_cast<const Env
* const*>(addr
);
472 return (*env
)->ValidateOptions(db_opts
, cf_opts
);
474 {"allow_data_in_errors",
475 {offsetof(struct ImmutableDBOptions
, allow_data_in_errors
),
476 OptionType::kBoolean
, OptionVerificationType::kNormal
,
477 OptionTypeFlags::kNone
}},
478 {"file_checksum_gen_factory",
479 OptionTypeInfo::AsCustomSharedPtr
<FileChecksumGenFactory
>(
480 offsetof(struct ImmutableDBOptions
, file_checksum_gen_factory
),
481 OptionVerificationType::kByNameAllowFromNull
,
482 OptionTypeFlags::kAllowNull
)},
484 OptionTypeInfo::AsCustomSharedPtr
<Statistics
>(
485 // Statistics should not be compared and can be null
486 // Statistics are maked "don't serialize" until they can be shared
488 offsetof(struct ImmutableDBOptions
, statistics
),
489 OptionVerificationType::kNormal
,
490 OptionTypeFlags::kCompareNever
| OptionTypeFlags::kDontSerialize
|
491 OptionTypeFlags::kAllowNull
)},
492 // Allow EventListeners that have a non-empty Name() to be read/written
493 // as options Each listener will either be
494 // - A simple name (e.g. "MyEventListener")
495 // - A name with properties (e.g. "{id=MyListener1; timeout=60}"
496 // Multiple listeners will be separated by a ":":
497 // - "MyListener0;{id=MyListener1; timeout=60}
499 {offsetof(struct ImmutableDBOptions
, listeners
), OptionType::kVector
,
500 OptionVerificationType::kByNameAllowNull
,
501 OptionTypeFlags::kCompareNever
,
502 [](const ConfigOptions
& opts
, const std::string
& /*name*/,
503 const std::string
& value
, void* addr
) {
504 ConfigOptions embedded
= opts
;
505 embedded
.ignore_unsupported_options
= true;
506 std::vector
<std::shared_ptr
<EventListener
>> listeners
;
508 for (size_t start
= 0, end
= 0;
509 s
.ok() && start
< value
.size() && end
!= std::string::npos
;
512 s
= OptionTypeInfo::NextToken(value
, ':', start
, &end
, &token
);
513 if (s
.ok() && !token
.empty()) {
514 std::shared_ptr
<EventListener
> listener
;
515 s
= EventListener::CreateFromString(embedded
, token
, &listener
);
516 if (s
.ok() && listener
!= nullptr) {
517 listeners
.push_back(listener
);
521 if (s
.ok()) { // It worked
522 *(static_cast<std::vector
<std::shared_ptr
<EventListener
>>*>(
527 [](const ConfigOptions
& opts
, const std::string
& /*name*/,
528 const void* addr
, std::string
* value
) {
529 const auto listeners
=
530 static_cast<const std::vector
<std::shared_ptr
<EventListener
>>*>(
532 ConfigOptions embedded
= opts
;
533 embedded
.delimiter
= ";";
535 for (const auto& listener
: *listeners
) {
536 auto id
= listener
->GetId();
538 std::string elem_str
= listener
->ToString(embedded
, "");
539 if (printed
++ == 0) {
544 value
->append(elem_str
);
553 {"lowest_used_cache_tier",
554 OptionTypeInfo::Enum
<CacheTier
>(
555 offsetof(struct ImmutableDBOptions
, lowest_used_cache_tier
),
556 &cache_tier_string_map
, OptionTypeFlags::kNone
)},
557 {"enforce_single_del_contracts",
558 {offsetof(struct ImmutableDBOptions
, enforce_single_del_contracts
),
559 OptionType::kBoolean
, OptionVerificationType::kNormal
,
560 OptionTypeFlags::kNone
}},
563 const std::string
OptionsHelper::kDBOptionsName
= "DBOptions";
565 class MutableDBConfigurable
: public Configurable
{
567 explicit MutableDBConfigurable(
568 const MutableDBOptions
& mdb
,
569 const std::unordered_map
<std::string
, std::string
>* map
= nullptr)
570 : mutable_(mdb
), opt_map_(map
) {
571 RegisterOptions(&mutable_
, &db_mutable_options_type_info
);
574 bool OptionsAreEqual(const ConfigOptions
& config_options
,
575 const OptionTypeInfo
& opt_info
,
576 const std::string
& opt_name
, const void* const this_ptr
,
577 const void* const that_ptr
,
578 std::string
* mismatch
) const override
{
579 bool equals
= opt_info
.AreEqual(config_options
, opt_name
, this_ptr
,
581 if (!equals
&& opt_info
.IsByName()) {
582 if (opt_map_
== nullptr) {
585 const auto& iter
= opt_map_
->find(opt_name
);
586 if (iter
== opt_map_
->end()) {
589 equals
= opt_info
.AreEqualByName(config_options
, opt_name
, this_ptr
,
593 if (equals
) { // False alarm, clear mismatch
597 if (equals
&& opt_info
.IsConfigurable() && opt_map_
!= nullptr) {
598 const auto* this_config
= opt_info
.AsRawPointer
<Configurable
>(this_ptr
);
599 if (this_config
== nullptr) {
600 const auto& iter
= opt_map_
->find(opt_name
);
601 // If the name exists in the map and is not empty/null,
602 // then the this_config should be set.
603 if (iter
!= opt_map_
->end() && !iter
->second
.empty() &&
604 iter
->second
!= kNullptrString
) {
605 *mismatch
= opt_name
;
614 MutableDBOptions mutable_
;
615 const std::unordered_map
<std::string
, std::string
>* opt_map_
;
618 class DBOptionsConfigurable
: public MutableDBConfigurable
{
620 explicit DBOptionsConfigurable(
621 const DBOptions
& opts
,
622 const std::unordered_map
<std::string
, std::string
>* map
= nullptr)
623 : MutableDBConfigurable(MutableDBOptions(opts
), map
), db_options_(opts
) {
624 // The ImmutableDBOptions currently requires the env to be non-null. Make
626 if (opts
.env
!= nullptr) {
627 immutable_
= ImmutableDBOptions(opts
);
629 DBOptions copy
= opts
;
630 copy
.env
= Env::Default();
631 immutable_
= ImmutableDBOptions(copy
);
633 RegisterOptions(&immutable_
, &db_immutable_options_type_info
);
637 Status
ConfigureOptions(
638 const ConfigOptions
& config_options
,
639 const std::unordered_map
<std::string
, std::string
>& opts_map
,
640 std::unordered_map
<std::string
, std::string
>* unused
) override
{
641 Status s
= Configurable::ConfigureOptions(config_options
, opts_map
, unused
);
643 db_options_
= BuildDBOptions(immutable_
, mutable_
);
644 s
= PrepareOptions(config_options
);
649 const void* GetOptionsPtr(const std::string
& name
) const override
{
650 if (name
== OptionsHelper::kDBOptionsName
) {
653 return MutableDBConfigurable::GetOptionsPtr(name
);
658 ImmutableDBOptions immutable_
;
659 DBOptions db_options_
;
662 std::unique_ptr
<Configurable
> DBOptionsAsConfigurable(
663 const MutableDBOptions
& opts
) {
664 std::unique_ptr
<Configurable
> ptr(new MutableDBConfigurable(opts
));
667 std::unique_ptr
<Configurable
> DBOptionsAsConfigurable(
668 const DBOptions
& opts
,
669 const std::unordered_map
<std::string
, std::string
>* opt_map
) {
670 std::unique_ptr
<Configurable
> ptr(new DBOptionsConfigurable(opts
, opt_map
));
673 #endif // ROCKSDB_LITE
675 ImmutableDBOptions::ImmutableDBOptions() : ImmutableDBOptions(Options()) {}
677 ImmutableDBOptions::ImmutableDBOptions(const DBOptions
& options
)
678 : create_if_missing(options
.create_if_missing
),
679 create_missing_column_families(options
.create_missing_column_families
),
680 error_if_exists(options
.error_if_exists
),
681 paranoid_checks(options
.paranoid_checks
),
682 flush_verify_memtable_count(options
.flush_verify_memtable_count
),
683 track_and_verify_wals_in_manifest(
684 options
.track_and_verify_wals_in_manifest
),
685 verify_sst_unique_id_in_manifest(
686 options
.verify_sst_unique_id_in_manifest
),
688 rate_limiter(options
.rate_limiter
),
689 sst_file_manager(options
.sst_file_manager
),
690 info_log(options
.info_log
),
691 info_log_level(options
.info_log_level
),
692 max_file_opening_threads(options
.max_file_opening_threads
),
693 statistics(options
.statistics
),
694 use_fsync(options
.use_fsync
),
695 db_paths(options
.db_paths
),
696 db_log_dir(options
.db_log_dir
),
697 wal_dir(options
.wal_dir
),
698 max_log_file_size(options
.max_log_file_size
),
699 log_file_time_to_roll(options
.log_file_time_to_roll
),
700 keep_log_file_num(options
.keep_log_file_num
),
701 recycle_log_file_num(options
.recycle_log_file_num
),
702 max_manifest_file_size(options
.max_manifest_file_size
),
703 table_cache_numshardbits(options
.table_cache_numshardbits
),
704 WAL_ttl_seconds(options
.WAL_ttl_seconds
),
705 WAL_size_limit_MB(options
.WAL_size_limit_MB
),
706 max_write_batch_group_size_bytes(
707 options
.max_write_batch_group_size_bytes
),
708 manifest_preallocation_size(options
.manifest_preallocation_size
),
709 allow_mmap_reads(options
.allow_mmap_reads
),
710 allow_mmap_writes(options
.allow_mmap_writes
),
711 use_direct_reads(options
.use_direct_reads
),
712 use_direct_io_for_flush_and_compaction(
713 options
.use_direct_io_for_flush_and_compaction
),
714 allow_fallocate(options
.allow_fallocate
),
715 is_fd_close_on_exec(options
.is_fd_close_on_exec
),
716 advise_random_on_open(options
.advise_random_on_open
),
717 db_write_buffer_size(options
.db_write_buffer_size
),
718 write_buffer_manager(options
.write_buffer_manager
),
719 access_hint_on_compaction_start(options
.access_hint_on_compaction_start
),
720 random_access_max_buffer_size(options
.random_access_max_buffer_size
),
721 use_adaptive_mutex(options
.use_adaptive_mutex
),
722 listeners(options
.listeners
),
723 enable_thread_tracking(options
.enable_thread_tracking
),
724 enable_pipelined_write(options
.enable_pipelined_write
),
725 unordered_write(options
.unordered_write
),
726 allow_concurrent_memtable_write(options
.allow_concurrent_memtable_write
),
727 enable_write_thread_adaptive_yield(
728 options
.enable_write_thread_adaptive_yield
),
729 write_thread_max_yield_usec(options
.write_thread_max_yield_usec
),
730 write_thread_slow_yield_usec(options
.write_thread_slow_yield_usec
),
731 skip_stats_update_on_db_open(options
.skip_stats_update_on_db_open
),
732 skip_checking_sst_file_sizes_on_db_open(
733 options
.skip_checking_sst_file_sizes_on_db_open
),
734 wal_recovery_mode(options
.wal_recovery_mode
),
735 allow_2pc(options
.allow_2pc
),
736 row_cache(options
.row_cache
),
738 wal_filter(options
.wal_filter
),
739 #endif // ROCKSDB_LITE
740 fail_if_options_file_error(options
.fail_if_options_file_error
),
741 dump_malloc_stats(options
.dump_malloc_stats
),
742 avoid_flush_during_recovery(options
.avoid_flush_during_recovery
),
743 allow_ingest_behind(options
.allow_ingest_behind
),
744 two_write_queues(options
.two_write_queues
),
745 manual_wal_flush(options
.manual_wal_flush
),
746 wal_compression(options
.wal_compression
),
747 atomic_flush(options
.atomic_flush
),
748 avoid_unnecessary_blocking_io(options
.avoid_unnecessary_blocking_io
),
749 persist_stats_to_disk(options
.persist_stats_to_disk
),
750 write_dbid_to_manifest(options
.write_dbid_to_manifest
),
751 log_readahead_size(options
.log_readahead_size
),
752 file_checksum_gen_factory(options
.file_checksum_gen_factory
),
753 best_efforts_recovery(options
.best_efforts_recovery
),
754 max_bgerror_resume_count(options
.max_bgerror_resume_count
),
755 bgerror_resume_retry_interval(options
.bgerror_resume_retry_interval
),
756 allow_data_in_errors(options
.allow_data_in_errors
),
757 db_host_id(options
.db_host_id
),
758 checksum_handoff_file_types(options
.checksum_handoff_file_types
),
759 lowest_used_cache_tier(options
.lowest_used_cache_tier
),
760 compaction_service(options
.compaction_service
),
761 enforce_single_del_contracts(options
.enforce_single_del_contracts
) {
762 fs
= env
->GetFileSystem();
763 clock
= env
->GetSystemClock().get();
764 logger
= info_log
.get();
765 stats
= statistics
.get();
768 void ImmutableDBOptions::Dump(Logger
* log
) const {
769 ROCKS_LOG_HEADER(log
, " Options.error_if_exists: %d",
771 ROCKS_LOG_HEADER(log
, " Options.create_if_missing: %d",
773 ROCKS_LOG_HEADER(log
, " Options.paranoid_checks: %d",
775 ROCKS_LOG_HEADER(log
, " Options.flush_verify_memtable_count: %d",
776 flush_verify_memtable_count
);
777 ROCKS_LOG_HEADER(log
,
779 "Options.track_and_verify_wals_in_manifest: %d",
780 track_and_verify_wals_in_manifest
);
781 ROCKS_LOG_HEADER(log
, " Options.verify_sst_unique_id_in_manifest: %d",
782 verify_sst_unique_id_in_manifest
);
783 ROCKS_LOG_HEADER(log
, " Options.env: %p",
785 ROCKS_LOG_HEADER(log
, " Options.fs: %s",
787 ROCKS_LOG_HEADER(log
, " Options.info_log: %p",
789 ROCKS_LOG_HEADER(log
, " Options.max_file_opening_threads: %d",
790 max_file_opening_threads
);
791 ROCKS_LOG_HEADER(log
, " Options.statistics: %p",
793 ROCKS_LOG_HEADER(log
, " Options.use_fsync: %d",
796 log
, " Options.max_log_file_size: %" ROCKSDB_PRIszt
,
798 ROCKS_LOG_HEADER(log
,
799 " Options.max_manifest_file_size: %" PRIu64
,
800 max_manifest_file_size
);
802 log
, " Options.log_file_time_to_roll: %" ROCKSDB_PRIszt
,
803 log_file_time_to_roll
);
805 log
, " Options.keep_log_file_num: %" ROCKSDB_PRIszt
,
808 log
, " Options.recycle_log_file_num: %" ROCKSDB_PRIszt
,
809 recycle_log_file_num
);
810 ROCKS_LOG_HEADER(log
, " Options.allow_fallocate: %d",
812 ROCKS_LOG_HEADER(log
, " Options.allow_mmap_reads: %d",
814 ROCKS_LOG_HEADER(log
, " Options.allow_mmap_writes: %d",
816 ROCKS_LOG_HEADER(log
, " Options.use_direct_reads: %d",
818 ROCKS_LOG_HEADER(log
,
820 "Options.use_direct_io_for_flush_and_compaction: %d",
821 use_direct_io_for_flush_and_compaction
);
822 ROCKS_LOG_HEADER(log
, " Options.create_missing_column_families: %d",
823 create_missing_column_families
);
824 ROCKS_LOG_HEADER(log
, " Options.db_log_dir: %s",
826 ROCKS_LOG_HEADER(log
, " Options.wal_dir: %s",
828 ROCKS_LOG_HEADER(log
, " Options.table_cache_numshardbits: %d",
829 table_cache_numshardbits
);
830 ROCKS_LOG_HEADER(log
,
831 " Options.WAL_ttl_seconds: %" PRIu64
,
833 ROCKS_LOG_HEADER(log
,
834 " Options.WAL_size_limit_MB: %" PRIu64
,
836 ROCKS_LOG_HEADER(log
,
838 "Options.max_write_batch_group_size_bytes: %" PRIu64
,
839 max_write_batch_group_size_bytes
);
841 log
, " Options.manifest_preallocation_size: %" ROCKSDB_PRIszt
,
842 manifest_preallocation_size
);
843 ROCKS_LOG_HEADER(log
, " Options.is_fd_close_on_exec: %d",
844 is_fd_close_on_exec
);
845 ROCKS_LOG_HEADER(log
, " Options.advise_random_on_open: %d",
846 advise_random_on_open
);
848 log
, " Options.db_write_buffer_size: %" ROCKSDB_PRIszt
,
849 db_write_buffer_size
);
850 ROCKS_LOG_HEADER(log
, " Options.write_buffer_manager: %p",
851 write_buffer_manager
.get());
852 ROCKS_LOG_HEADER(log
, " Options.access_hint_on_compaction_start: %d",
853 static_cast<int>(access_hint_on_compaction_start
));
855 log
, " Options.random_access_max_buffer_size: %" ROCKSDB_PRIszt
,
856 random_access_max_buffer_size
);
857 ROCKS_LOG_HEADER(log
, " Options.use_adaptive_mutex: %d",
859 ROCKS_LOG_HEADER(log
, " Options.rate_limiter: %p",
862 log
, " Options.sst_file_manager.rate_bytes_per_sec: %" PRIi64
,
863 sst_file_manager
? sst_file_manager
->GetDeleteRateBytesPerSecond() : 0);
864 ROCKS_LOG_HEADER(log
, " Options.wal_recovery_mode: %d",
865 static_cast<int>(wal_recovery_mode
));
866 ROCKS_LOG_HEADER(log
, " Options.enable_thread_tracking: %d",
867 enable_thread_tracking
);
868 ROCKS_LOG_HEADER(log
, " Options.enable_pipelined_write: %d",
869 enable_pipelined_write
);
870 ROCKS_LOG_HEADER(log
, " Options.unordered_write: %d",
872 ROCKS_LOG_HEADER(log
, " Options.allow_concurrent_memtable_write: %d",
873 allow_concurrent_memtable_write
);
874 ROCKS_LOG_HEADER(log
, " Options.enable_write_thread_adaptive_yield: %d",
875 enable_write_thread_adaptive_yield
);
876 ROCKS_LOG_HEADER(log
,
877 " Options.write_thread_max_yield_usec: %" PRIu64
,
878 write_thread_max_yield_usec
);
879 ROCKS_LOG_HEADER(log
,
880 " Options.write_thread_slow_yield_usec: %" PRIu64
,
881 write_thread_slow_yield_usec
);
885 " Options.row_cache: %" ROCKSDB_PRIszt
,
886 row_cache
->GetCapacity());
888 ROCKS_LOG_HEADER(log
,
889 " Options.row_cache: None");
892 ROCKS_LOG_HEADER(log
, " Options.wal_filter: %s",
893 wal_filter
? wal_filter
->Name() : "None");
894 #endif // ROCKDB_LITE
896 ROCKS_LOG_HEADER(log
, " Options.avoid_flush_during_recovery: %d",
897 avoid_flush_during_recovery
);
898 ROCKS_LOG_HEADER(log
, " Options.allow_ingest_behind: %d",
899 allow_ingest_behind
);
900 ROCKS_LOG_HEADER(log
, " Options.two_write_queues: %d",
902 ROCKS_LOG_HEADER(log
, " Options.manual_wal_flush: %d",
904 ROCKS_LOG_HEADER(log
, " Options.wal_compression: %d",
906 ROCKS_LOG_HEADER(log
, " Options.atomic_flush: %d", atomic_flush
);
907 ROCKS_LOG_HEADER(log
,
908 " Options.avoid_unnecessary_blocking_io: %d",
909 avoid_unnecessary_blocking_io
);
910 ROCKS_LOG_HEADER(log
, " Options.persist_stats_to_disk: %u",
911 persist_stats_to_disk
);
912 ROCKS_LOG_HEADER(log
, " Options.write_dbid_to_manifest: %d",
913 write_dbid_to_manifest
);
915 log
, " Options.log_readahead_size: %" ROCKSDB_PRIszt
,
917 ROCKS_LOG_HEADER(log
, " Options.file_checksum_gen_factory: %s",
918 file_checksum_gen_factory
? file_checksum_gen_factory
->Name()
919 : kUnknownFileChecksumFuncName
);
920 ROCKS_LOG_HEADER(log
, " Options.best_efforts_recovery: %d",
921 static_cast<int>(best_efforts_recovery
));
922 ROCKS_LOG_HEADER(log
, " Options.max_bgerror_resume_count: %d",
923 max_bgerror_resume_count
);
924 ROCKS_LOG_HEADER(log
,
925 " Options.bgerror_resume_retry_interval: %" PRIu64
,
926 bgerror_resume_retry_interval
);
927 ROCKS_LOG_HEADER(log
, " Options.allow_data_in_errors: %d",
928 allow_data_in_errors
);
929 ROCKS_LOG_HEADER(log
, " Options.db_host_id: %s",
931 ROCKS_LOG_HEADER(log
, " Options.enforce_single_del_contracts: %s",
932 enforce_single_del_contracts
? "true" : "false");
935 bool ImmutableDBOptions::IsWalDirSameAsDBPath() const {
936 assert(!db_paths
.empty());
937 return IsWalDirSameAsDBPath(db_paths
[0].path
);
940 bool ImmutableDBOptions::IsWalDirSameAsDBPath(
941 const std::string
& db_path
) const {
942 bool same
= wal_dir
.empty();
944 Status s
= env
->AreFilesSame(wal_dir
, db_path
, &same
);
945 if (s
.IsNotSupported()) {
946 same
= wal_dir
== db_path
;
952 const std::string
& ImmutableDBOptions::GetWalDir() const {
953 if (wal_dir
.empty()) {
954 assert(!db_paths
.empty());
955 return db_paths
[0].path
;
961 const std::string
& ImmutableDBOptions::GetWalDir(
962 const std::string
& path
) const {
963 if (wal_dir
.empty()) {
970 MutableDBOptions::MutableDBOptions()
971 : max_background_jobs(2),
972 max_background_compactions(-1),
973 max_subcompactions(0),
974 avoid_flush_during_shutdown(false),
975 writable_file_max_buffer_size(1024 * 1024),
976 delayed_write_rate(2 * 1024U * 1024U),
977 max_total_wal_size(0),
978 delete_obsolete_files_period_micros(6ULL * 60 * 60 * 1000000),
979 stats_dump_period_sec(600),
980 stats_persist_period_sec(600),
981 stats_history_buffer_size(1024 * 1024),
984 wal_bytes_per_sync(0),
985 strict_bytes_per_sync(false),
986 compaction_readahead_size(0),
987 max_background_flushes(-1) {}
989 MutableDBOptions::MutableDBOptions(const DBOptions
& options
)
990 : max_background_jobs(options
.max_background_jobs
),
991 max_background_compactions(options
.max_background_compactions
),
992 max_subcompactions(options
.max_subcompactions
),
993 avoid_flush_during_shutdown(options
.avoid_flush_during_shutdown
),
994 writable_file_max_buffer_size(options
.writable_file_max_buffer_size
),
995 delayed_write_rate(options
.delayed_write_rate
),
996 max_total_wal_size(options
.max_total_wal_size
),
997 delete_obsolete_files_period_micros(
998 options
.delete_obsolete_files_period_micros
),
999 stats_dump_period_sec(options
.stats_dump_period_sec
),
1000 stats_persist_period_sec(options
.stats_persist_period_sec
),
1001 stats_history_buffer_size(options
.stats_history_buffer_size
),
1002 max_open_files(options
.max_open_files
),
1003 bytes_per_sync(options
.bytes_per_sync
),
1004 wal_bytes_per_sync(options
.wal_bytes_per_sync
),
1005 strict_bytes_per_sync(options
.strict_bytes_per_sync
),
1006 compaction_readahead_size(options
.compaction_readahead_size
),
1007 max_background_flushes(options
.max_background_flushes
) {}
1009 void MutableDBOptions::Dump(Logger
* log
) const {
1010 ROCKS_LOG_HEADER(log
, " Options.max_background_jobs: %d",
1011 max_background_jobs
);
1012 ROCKS_LOG_HEADER(log
, " Options.max_background_compactions: %d",
1013 max_background_compactions
);
1014 ROCKS_LOG_HEADER(log
, " Options.max_subcompactions: %" PRIu32
,
1015 max_subcompactions
);
1016 ROCKS_LOG_HEADER(log
, " Options.avoid_flush_during_shutdown: %d",
1017 avoid_flush_during_shutdown
);
1019 log
, " Options.writable_file_max_buffer_size: %" ROCKSDB_PRIszt
,
1020 writable_file_max_buffer_size
);
1021 ROCKS_LOG_HEADER(log
, " Options.delayed_write_rate : %" PRIu64
,
1022 delayed_write_rate
);
1023 ROCKS_LOG_HEADER(log
, " Options.max_total_wal_size: %" PRIu64
,
1024 max_total_wal_size
);
1026 log
, " Options.delete_obsolete_files_period_micros: %" PRIu64
,
1027 delete_obsolete_files_period_micros
);
1028 ROCKS_LOG_HEADER(log
, " Options.stats_dump_period_sec: %u",
1029 stats_dump_period_sec
);
1030 ROCKS_LOG_HEADER(log
, " Options.stats_persist_period_sec: %d",
1031 stats_persist_period_sec
);
1034 " Options.stats_history_buffer_size: %" ROCKSDB_PRIszt
,
1035 stats_history_buffer_size
);
1036 ROCKS_LOG_HEADER(log
, " Options.max_open_files: %d",
1038 ROCKS_LOG_HEADER(log
,
1039 " Options.bytes_per_sync: %" PRIu64
,
1041 ROCKS_LOG_HEADER(log
,
1042 " Options.wal_bytes_per_sync: %" PRIu64
,
1043 wal_bytes_per_sync
);
1044 ROCKS_LOG_HEADER(log
,
1045 " Options.strict_bytes_per_sync: %d",
1046 strict_bytes_per_sync
);
1047 ROCKS_LOG_HEADER(log
,
1048 " Options.compaction_readahead_size: %" ROCKSDB_PRIszt
,
1049 compaction_readahead_size
);
1050 ROCKS_LOG_HEADER(log
, " Options.max_background_flushes: %d",
1051 max_background_flushes
);
1054 #ifndef ROCKSDB_LITE
1055 Status
GetMutableDBOptionsFromStrings(
1056 const MutableDBOptions
& base_options
,
1057 const std::unordered_map
<std::string
, std::string
>& options_map
,
1058 MutableDBOptions
* new_options
) {
1059 assert(new_options
);
1060 *new_options
= base_options
;
1061 ConfigOptions config_options
;
1062 Status s
= OptionTypeInfo::ParseType(
1063 config_options
, options_map
, db_mutable_options_type_info
, new_options
);
1065 *new_options
= base_options
;
1070 bool MutableDBOptionsAreEqual(const MutableDBOptions
& this_options
,
1071 const MutableDBOptions
& that_options
) {
1072 ConfigOptions config_options
;
1073 std::string mismatch
;
1074 return OptionTypeInfo::StructsAreEqual(
1075 config_options
, "MutableDBOptions", &db_mutable_options_type_info
,
1076 "MutableDBOptions", &this_options
, &that_options
, &mismatch
);
1079 Status
GetStringFromMutableDBOptions(const ConfigOptions
& config_options
,
1080 const MutableDBOptions
& mutable_opts
,
1081 std::string
* opt_string
) {
1082 return OptionTypeInfo::SerializeType(
1083 config_options
, db_mutable_options_type_info
, &mutable_opts
, opt_string
);
1085 #endif // ROCKSDB_LITE
1086 } // namespace ROCKSDB_NAMESPACE