2016-09-23 23:34:04 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2016-09-23 23:34:04 +00:00
|
|
|
|
2017-04-06 02:02:00 +00:00
|
|
|
#include "options/db_options.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
|
2019-06-06 20:52:39 +00:00
|
|
|
#include <cinttypes>
|
2016-09-23 23:34:04 +00:00
|
|
|
|
2019-06-01 00:19:43 +00:00
|
|
|
#include "logging/logging.h"
|
2020-09-14 23:59:00 +00:00
|
|
|
#include "options/configurable_helper.h"
|
2020-04-03 17:48:46 +00:00
|
|
|
#include "options/options_helper.h"
|
2020-09-14 23:59:00 +00:00
|
|
|
#include "options/options_parser.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
#include "port/port.h"
|
2023-02-09 20:12:02 +00:00
|
|
|
#include "rocksdb/advanced_cache.h"
|
2020-09-14 23:59:00 +00:00
|
|
|
#include "rocksdb/configurable.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
#include "rocksdb/env.h"
|
Introduce a new storage specific Env API (#5761)
Summary:
The current Env API encompasses both storage/file operations, as well as OS related operations. Most of the APIs return a Status, which does not have enough metadata about an error, such as whether its retry-able or not, scope (i.e fault domain) of the error etc., that may be required in order to properly handle a storage error. The file APIs also do not provide enough control over the IO SLA, such as timeout, prioritization, hinting about placement and redundancy etc.
This PR separates out the file/storage APIs from Env into a new FileSystem class. The APIs are updated to return an IOStatus with metadata about the error, as well as to take an IOOptions structure as input in order to allow more control over the IO.
The user can set both ```options.env``` and ```options.file_system``` to specify that RocksDB should use the former for OS related operations and the latter for storage operations. Internally, a ```CompositeEnvWrapper``` has been introduced that inherits from ```Env``` and redirects individual methods to either an ```Env``` implementation or the ```FileSystem``` as appropriate. When options are sanitized during ```DB::Open```, ```options.env``` is replaced with a newly allocated ```CompositeEnvWrapper``` instance if both env and file_system have been specified. This way, the rest of the RocksDB code can continue to function as before.
This PR also ports PosixEnv to the new API by splitting it into two - PosixEnv and PosixFileSystem. PosixEnv is defined as a sub-class of CompositeEnvWrapper, and threading/time functions are overridden with Posix specific implementations in order to avoid an extra level of indirection.
The ```CompositeEnvWrapper``` translates ```IOStatus``` return code to ```Status```, and sets the severity to ```kSoftError``` if the io_status is retryable. The error handling code in RocksDB can then recover the DB automatically.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5761
Differential Revision: D18868376
Pulled By: anand1976
fbshipit-source-id: 39efe18a162ea746fabac6360ff529baba48486f
2019-12-13 22:47:08 +00:00
|
|
|
#include "rocksdb/file_system.h"
|
2021-07-27 14:46:09 +00:00
|
|
|
#include "rocksdb/listener.h"
|
2020-04-29 01:02:11 +00:00
|
|
|
#include "rocksdb/rate_limiter.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
#include "rocksdb/sst_file_manager.h"
|
2021-09-10 16:46:47 +00:00
|
|
|
#include "rocksdb/statistics.h"
|
2021-03-15 11:32:24 +00:00
|
|
|
#include "rocksdb/system_clock.h"
|
2020-09-14 23:59:00 +00:00
|
|
|
#include "rocksdb/utilities/options_type.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
#include "rocksdb/wal_filter.h"
|
2020-09-14 23:59:00 +00:00
|
|
|
#include "util/string_util.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2020-05-05 22:02:04 +00:00
|
|
|
static std::unordered_map<std::string, WALRecoveryMode>
|
|
|
|
wal_recovery_mode_string_map = {
|
|
|
|
{"kTolerateCorruptedTailRecords",
|
|
|
|
WALRecoveryMode::kTolerateCorruptedTailRecords},
|
|
|
|
{"kAbsoluteConsistency", WALRecoveryMode::kAbsoluteConsistency},
|
|
|
|
{"kPointInTimeRecovery", WALRecoveryMode::kPointInTimeRecovery},
|
|
|
|
{"kSkipAnyCorruptedRecords",
|
|
|
|
WALRecoveryMode::kSkipAnyCorruptedRecords}};
|
|
|
|
|
2021-10-19 22:53:16 +00:00
|
|
|
static std::unordered_map<std::string, CacheTier> cache_tier_string_map = {
|
|
|
|
{"kVolatileTier", CacheTier::kVolatileTier},
|
2024-04-08 16:48:03 +00:00
|
|
|
{"kVolatileCompressedTier", CacheTier::kVolatileCompressedTier},
|
2021-10-19 22:53:16 +00:00
|
|
|
{"kNonVolatileBlockTier", CacheTier::kNonVolatileBlockTier}};
|
|
|
|
|
2020-05-05 22:02:04 +00:00
|
|
|
static std::unordered_map<std::string, InfoLogLevel> info_log_level_string_map =
|
|
|
|
{{"DEBUG_LEVEL", InfoLogLevel::DEBUG_LEVEL},
|
|
|
|
{"INFO_LEVEL", InfoLogLevel::INFO_LEVEL},
|
|
|
|
{"WARN_LEVEL", InfoLogLevel::WARN_LEVEL},
|
|
|
|
{"ERROR_LEVEL", InfoLogLevel::ERROR_LEVEL},
|
|
|
|
{"FATAL_LEVEL", InfoLogLevel::FATAL_LEVEL},
|
|
|
|
{"HEADER_LEVEL", InfoLogLevel::HEADER_LEVEL}};
|
|
|
|
|
2020-09-14 23:59:00 +00:00
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
db_mutable_options_type_info = {
|
|
|
|
{"allow_os_buffer",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2022-01-28 05:03:38 +00:00
|
|
|
{"base_background_compactions",
|
|
|
|
{0, OptionType::kInt, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2020-09-14 23:59:00 +00:00
|
|
|
{"max_background_jobs",
|
|
|
|
{offsetof(struct MutableDBOptions, max_background_jobs),
|
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"max_background_compactions",
|
|
|
|
{offsetof(struct MutableDBOptions, max_background_compactions),
|
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"max_subcompactions",
|
|
|
|
{offsetof(struct MutableDBOptions, max_subcompactions),
|
|
|
|
OptionType::kUInt32T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"avoid_flush_during_shutdown",
|
|
|
|
{offsetof(struct MutableDBOptions, avoid_flush_during_shutdown),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2024-05-21 00:33:43 +00:00
|
|
|
{"avoid_sync_during_shutdown",
|
|
|
|
{offsetof(struct MutableDBOptions, avoid_sync_during_shutdown),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2020-09-14 23:59:00 +00:00
|
|
|
{"writable_file_max_buffer_size",
|
|
|
|
{offsetof(struct MutableDBOptions, writable_file_max_buffer_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"delayed_write_rate",
|
|
|
|
{offsetof(struct MutableDBOptions, delayed_write_rate),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"max_total_wal_size",
|
|
|
|
{offsetof(struct MutableDBOptions, max_total_wal_size),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"delete_obsolete_files_period_micros",
|
|
|
|
{offsetof(struct MutableDBOptions,
|
|
|
|
delete_obsolete_files_period_micros),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"stats_dump_period_sec",
|
|
|
|
{offsetof(struct MutableDBOptions, stats_dump_period_sec),
|
|
|
|
OptionType::kUInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"stats_persist_period_sec",
|
|
|
|
{offsetof(struct MutableDBOptions, stats_persist_period_sec),
|
|
|
|
OptionType::kUInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"stats_history_buffer_size",
|
|
|
|
{offsetof(struct MutableDBOptions, stats_history_buffer_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"max_open_files",
|
|
|
|
{offsetof(struct MutableDBOptions, max_open_files), OptionType::kInt,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
|
|
|
{"bytes_per_sync",
|
|
|
|
{offsetof(struct MutableDBOptions, bytes_per_sync),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"wal_bytes_per_sync",
|
|
|
|
{offsetof(struct MutableDBOptions, wal_bytes_per_sync),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"strict_bytes_per_sync",
|
|
|
|
{offsetof(struct MutableDBOptions, strict_bytes_per_sync),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"compaction_readahead_size",
|
|
|
|
{offsetof(struct MutableDBOptions, compaction_readahead_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"max_background_flushes",
|
|
|
|
{offsetof(struct MutableDBOptions, max_background_flushes),
|
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
Offpeak in db option (#11893)
Summary:
RocksDB's primary function is to facilitate read and write operations. Compactions, while essential for minimizing read amplifications and optimizing storage, can sometimes compete with these primary tasks. Especially during periods of high read/write traffic, it's vital to ensure that primary operations receive priority, avoiding any potential disruptions or slowdowns. Conversely, during off-peak times when traffic is minimal, it's an opportune moment to tackle low-priority tasks like TTL based compactions, optimizing resource usage.
In this PR, we are incorporating the concept of off-peak time into RocksDB by introducing `daily_offpeak_time_utc` within the DBOptions. This setting is formatted as "HH:mm-HH:mm" where the first one before "-" is the start time and the second one is the end time, inclusive. It will be later used for resource optimization in subsequent PRs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11893
Test Plan:
- New Unit Test Added - `DBOptionsTest::OffPeakTimes`
- Existing Unit Test Updated - `OptionsTest`, `OptionsSettableTest`
Reviewed By: pdillinger
Differential Revision: D49714553
Pulled By: jaykorean
fbshipit-source-id: fef51ea7c0fede6431c715bff116ddbb567c8752
2023-09-29 20:03:39 +00:00
|
|
|
{"daily_offpeak_time_utc",
|
|
|
|
{offsetof(struct MutableDBOptions, daily_offpeak_time_utc),
|
|
|
|
OptionType::kString, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2020-09-14 23:59:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
db_immutable_options_type_info = {
|
2020-04-03 17:48:46 +00:00
|
|
|
/*
|
|
|
|
// not yet supported
|
|
|
|
std::shared_ptr<Cache> row_cache;
|
|
|
|
std::shared_ptr<DeleteScheduler> delete_scheduler;
|
|
|
|
std::shared_ptr<Logger> info_log;
|
|
|
|
std::shared_ptr<RateLimiter> rate_limiter;
|
|
|
|
std::shared_ptr<Statistics> statistics;
|
|
|
|
std::vector<DbPath> db_paths;
|
2021-02-11 06:18:33 +00:00
|
|
|
FileTypeSet checksum_handoff_file_types;
|
2020-04-03 17:48:46 +00:00
|
|
|
*/
|
|
|
|
{"advise_random_on_open",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, advise_random_on_open),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"allow_mmap_reads",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, allow_mmap_reads),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"allow_fallocate",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, allow_fallocate),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"allow_mmap_writes",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, allow_mmap_writes),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"use_direct_reads",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, use_direct_reads),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"use_direct_writes",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"use_direct_io_for_flush_and_compaction",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions,
|
|
|
|
use_direct_io_for_flush_and_compaction),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"allow_2pc",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, allow_2pc), OptionType::kBoolean,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
|
2021-09-28 12:30:32 +00:00
|
|
|
{"wal_filter",
|
|
|
|
OptionTypeInfo::AsCustomRawPtr<WalFilter>(
|
|
|
|
offsetof(struct ImmutableDBOptions, wal_filter),
|
|
|
|
OptionVerificationType::kByName,
|
|
|
|
(OptionTypeFlags::kAllowNull | OptionTypeFlags::kCompareNever))},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"create_if_missing",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, create_if_missing),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"create_missing_column_families",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, create_missing_column_families),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"disableDataSync",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"disable_data_sync", // for compatibility
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"enable_thread_tracking",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, enable_thread_tracking),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"error_if_exists",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, error_if_exists),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2021-08-11 23:04:19 +00:00
|
|
|
{"experimental_allow_mempurge",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"experimental_mempurge_policy",
|
|
|
|
{0, OptionType::kString, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
2021-08-11 01:07:48 +00:00
|
|
|
{"experimental_mempurge_threshold",
|
2022-06-23 16:42:18 +00:00
|
|
|
{0, OptionType::kDouble, OptionVerificationType::kDeprecated,
|
Memtable "MemPurge" prototype (#8454)
Summary:
Implement an experimental feature called "MemPurge", which consists in purging "garbage" bytes out of a memtable and reuse the memtable struct instead of making it immutable and eventually flushing its content to storage.
The prototype is by default deactivated and is not intended for use. It is intended for correctness and validation testing. At the moment, the "MemPurge" feature can be switched on by using the `options.experimental_allow_mempurge` flag. For this early stage, when the allow_mempurge flag is set to `true`, all the flush operations will be rerouted to perform a MemPurge. This is a temporary design decision that will give us the time to explore meaningful heuristics to use MemPurge at the right time for relevant workloads . Moreover, the current MemPurge operation only supports `Puts`, `Deletes`, `DeleteRange` operations, and handles `Iterators` as well as `CompactionFilter`s that are invoked at flush time .
Three unit tests are added to `db_flush_test.cc` to test if MemPurge works correctly (and checks that the previously mentioned operations are fully supported thoroughly tested).
One noticeable design decision is the timing of the MemPurge operation in the memtable workflow: for this prototype, the mempurge happens when the memtable is switched (and usually made immutable). This is an inefficient process because it implies that the entirety of the MemPurge operation happens while holding the db_mutex. Future commits will make the MemPurge operation a background task (akin to the regular flush operation) and aim at drastically enhancing the performance of this operation. The MemPurge is also not fully "WAL-compatible" yet, but when the WAL is full, or when the regular MemPurge operation fails (or when the purged memtable still needs to be flushed), a regular flush operation takes place. Later commits will also correct these behaviors.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8454
Reviewed By: anand1976
Differential Revision: D29433971
Pulled By: bjlemaire
fbshipit-source-id: 6af48213554e35048a7e03816955100a80a26dc5
2021-07-02 12:22:03 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"is_fd_close_on_exec",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, is_fd_close_on_exec),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"paranoid_checks",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, paranoid_checks),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2021-05-20 23:06:12 +00:00
|
|
|
{"flush_verify_memtable_count",
|
|
|
|
{offsetof(struct ImmutableDBOptions, flush_verify_memtable_count),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2023-07-28 16:47:31 +00:00
|
|
|
{"compaction_verify_record_count",
|
|
|
|
{offsetof(struct ImmutableDBOptions, compaction_verify_record_count),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-10-09 23:40:25 +00:00
|
|
|
{"track_and_verify_wals_in_manifest",
|
|
|
|
{offsetof(struct ImmutableDBOptions,
|
|
|
|
track_and_verify_wals_in_manifest),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2022-05-19 18:04:21 +00:00
|
|
|
{"verify_sst_unique_id_in_manifest",
|
|
|
|
{offsetof(struct ImmutableDBOptions, verify_sst_unique_id_in_manifest),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-09-14 23:59:00 +00:00
|
|
|
{"skip_log_error_on_recovery",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"skip_stats_update_on_db_open",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, skip_stats_update_on_db_open),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"skip_checking_sst_file_sizes_on_db_open",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions,
|
|
|
|
skip_checking_sst_file_sizes_on_db_open),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"new_table_reader_for_compaction_inputs",
|
2022-02-09 03:27:46 +00:00
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"random_access_max_buffer_size",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, random_access_max_buffer_size),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"use_adaptive_mutex",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, use_adaptive_mutex),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"use_fsync",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, use_fsync), OptionType::kBoolean,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"max_file_opening_threads",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, max_file_opening_threads),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"table_cache_numshardbits",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, table_cache_numshardbits),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"db_write_buffer_size",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, db_write_buffer_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"keep_log_file_num",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, keep_log_file_num),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"recycle_log_file_num",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, recycle_log_file_num),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"log_file_time_to_roll",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, log_file_time_to_roll),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"manifest_preallocation_size",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, manifest_preallocation_size),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"max_log_file_size",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, max_log_file_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"db_log_dir",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, db_log_dir), OptionType::kString,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"wal_dir",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, wal_dir), OptionType::kString,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"WAL_size_limit_MB",
|
2021-04-23 03:42:50 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, WAL_size_limit_MB),
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"WAL_ttl_seconds",
|
2021-04-23 03:42:50 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, WAL_ttl_seconds),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"max_manifest_file_size",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, max_manifest_file_size),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"persist_stats_to_disk",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, persist_stats_to_disk),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"fail_if_options_file_error",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, fail_if_options_file_error),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"enable_pipelined_write",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, enable_pipelined_write),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"unordered_write",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, unordered_write),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"allow_concurrent_memtable_write",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, allow_concurrent_memtable_write),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"wal_recovery_mode",
|
|
|
|
OptionTypeInfo::Enum<WALRecoveryMode>(
|
|
|
|
offsetof(struct ImmutableDBOptions, wal_recovery_mode),
|
|
|
|
&wal_recovery_mode_string_map)},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"enable_write_thread_adaptive_yield",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions,
|
|
|
|
enable_write_thread_adaptive_yield),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"write_thread_slow_yield_usec",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, write_thread_slow_yield_usec),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"max_write_batch_group_size_bytes",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, max_write_batch_group_size_bytes),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"write_thread_max_yield_usec",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, write_thread_max_yield_usec),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"access_hint_on_compaction_start",
|
2024-02-05 21:35:19 +00:00
|
|
|
OptionTypeInfo::Enum<bool>(0, nullptr, OptionTypeFlags::kNone,
|
|
|
|
OptionVerificationType::kDeprecated)},
|
2020-09-14 23:59:00 +00:00
|
|
|
{"info_log_level",
|
|
|
|
OptionTypeInfo::Enum<InfoLogLevel>(
|
|
|
|
offsetof(struct ImmutableDBOptions, info_log_level),
|
|
|
|
&info_log_level_string_map)},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"dump_malloc_stats",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, dump_malloc_stats),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"avoid_flush_during_recovery",
|
|
|
|
{offsetof(struct ImmutableDBOptions, avoid_flush_during_recovery),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"allow_ingest_behind",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, allow_ingest_behind),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"preserve_deletes",
|
2022-01-28 21:26:32 +00:00
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"concurrent_prepare", // Deprecated by two_write_queues
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"two_write_queues",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, two_write_queues),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"manual_wal_flush",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, manual_wal_flush),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2022-01-26 21:57:30 +00:00
|
|
|
{"wal_compression",
|
|
|
|
{offsetof(struct ImmutableDBOptions, wal_compression),
|
|
|
|
OptionType::kCompressionType, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"seq_per_batch",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"atomic_flush",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, atomic_flush),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"avoid_unnecessary_blocking_io",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, avoid_unnecessary_blocking_io),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"write_dbid_to_manifest",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, write_dbid_to_manifest),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"log_readahead_size",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, log_readahead_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
{"best_efforts_recovery",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, best_efforts_recovery),
|
2020-04-03 17:48:46 +00:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-07-15 18:02:44 +00:00
|
|
|
{"max_bgerror_resume_count",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, max_bgerror_resume_count),
|
2020-07-15 18:02:44 +00:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-07-15 18:02:44 +00:00
|
|
|
{"bgerror_resume_retry_interval",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, bgerror_resume_retry_interval),
|
2020-07-15 18:02:44 +00:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-14 23:59:00 +00:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-10-19 18:37:05 +00:00
|
|
|
{"db_host_id",
|
|
|
|
{offsetof(struct ImmutableDBOptions, db_host_id), OptionType::kString,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kCompareNever}},
|
2022-07-18 21:48:42 +00:00
|
|
|
// Temporarily deprecated due to race conditions (examples in PR 10375).
|
2021-12-01 14:55:59 +00:00
|
|
|
{"rate_limiter",
|
2022-07-18 21:48:42 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, rate_limiter),
|
|
|
|
OptionType::kUnknown, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kDontSerialize | OptionTypeFlags::kCompareNever}},
|
2020-04-29 01:02:11 +00:00
|
|
|
// The following properties were handled as special cases in ParseOption
|
|
|
|
// This means that the properties could be read from the options file
|
|
|
|
// but never written to the file or compared to each other.
|
|
|
|
{"rate_limiter_bytes_per_sec",
|
2020-09-14 23:59:00 +00:00
|
|
|
{offsetof(struct ImmutableDBOptions, rate_limiter),
|
|
|
|
OptionType::kUnknown, OptionVerificationType::kNormal,
|
|
|
|
(OptionTypeFlags::kDontSerialize | OptionTypeFlags::kCompareNever),
|
2020-04-29 01:02:11 +00:00
|
|
|
// Parse the input value as a RateLimiter
|
|
|
|
[](const ConfigOptions& /*opts*/, const std::string& /*name*/,
|
2021-05-13 21:28:50 +00:00
|
|
|
const std::string& value, void* addr) {
|
|
|
|
auto limiter = static_cast<std::shared_ptr<RateLimiter>*>(addr);
|
2020-04-29 01:02:11 +00:00
|
|
|
limiter->reset(NewGenericRateLimiter(
|
|
|
|
static_cast<int64_t>(ParseUint64(value))));
|
|
|
|
return Status::OK();
|
|
|
|
}}},
|
2022-05-13 11:57:08 +00:00
|
|
|
{"env", //**TODO: Should this be kCustomizable?
|
|
|
|
OptionTypeInfo(
|
|
|
|
offsetof(struct ImmutableDBOptions, env), OptionType::kUnknown,
|
|
|
|
OptionVerificationType::kNormal,
|
|
|
|
(OptionTypeFlags::kDontSerialize | OptionTypeFlags::kCompareNever))
|
|
|
|
.SetParseFunc([](const ConfigOptions& opts,
|
|
|
|
const std::string& /*name*/,
|
|
|
|
const std::string& value, void* addr) {
|
|
|
|
// Parse the input value as an Env
|
|
|
|
auto old_env = static_cast<Env**>(addr); // Get the old value
|
|
|
|
Env* new_env = *old_env; // Set new to old
|
|
|
|
Status s = Env::CreateFromString(opts, value,
|
|
|
|
&new_env); // Update new value
|
|
|
|
if (s.ok()) { // It worked
|
|
|
|
*old_env = new_env; // Update the old one
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
})
|
|
|
|
.SetPrepareFunc([](const ConfigOptions& opts,
|
|
|
|
const std::string& /*name*/, void* addr) {
|
|
|
|
auto env = static_cast<Env**>(addr);
|
|
|
|
return (*env)->PrepareOptions(opts);
|
|
|
|
})
|
|
|
|
.SetValidateFunc([](const DBOptions& db_opts,
|
|
|
|
const ColumnFamilyOptions& cf_opts,
|
|
|
|
const std::string& /*name*/,
|
|
|
|
const void* addr) {
|
|
|
|
const auto env = static_cast<const Env* const*>(addr);
|
|
|
|
return (*env)->ValidateOptions(db_opts, cf_opts);
|
|
|
|
})},
|
2020-09-30 06:16:12 +00:00
|
|
|
{"allow_data_in_errors",
|
|
|
|
{offsetof(struct ImmutableDBOptions, allow_data_in_errors),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2021-09-28 12:30:32 +00:00
|
|
|
{"file_checksum_gen_factory",
|
|
|
|
OptionTypeInfo::AsCustomSharedPtr<FileChecksumGenFactory>(
|
|
|
|
offsetof(struct ImmutableDBOptions, file_checksum_gen_factory),
|
2021-10-19 17:42:04 +00:00
|
|
|
OptionVerificationType::kByNameAllowFromNull,
|
|
|
|
OptionTypeFlags::kAllowNull)},
|
2021-09-10 16:46:47 +00:00
|
|
|
{"statistics",
|
|
|
|
OptionTypeInfo::AsCustomSharedPtr<Statistics>(
|
|
|
|
// Statistics should not be compared and can be null
|
|
|
|
// Statistics are maked "don't serialize" until they can be shared
|
|
|
|
// between DBs
|
|
|
|
offsetof(struct ImmutableDBOptions, statistics),
|
|
|
|
OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kCompareNever | OptionTypeFlags::kDontSerialize |
|
|
|
|
OptionTypeFlags::kAllowNull)},
|
2021-07-27 14:46:09 +00:00
|
|
|
// Allow EventListeners that have a non-empty Name() to be read/written
|
|
|
|
// as options Each listener will either be
|
|
|
|
// - A simple name (e.g. "MyEventListener")
|
|
|
|
// - A name with properties (e.g. "{id=MyListener1; timeout=60}"
|
|
|
|
// Multiple listeners will be separated by a ":":
|
|
|
|
// - "MyListener0;{id=MyListener1; timeout=60}
|
|
|
|
{"listeners",
|
|
|
|
{offsetof(struct ImmutableDBOptions, listeners), OptionType::kVector,
|
|
|
|
OptionVerificationType::kByNameAllowNull,
|
|
|
|
OptionTypeFlags::kCompareNever,
|
|
|
|
[](const ConfigOptions& opts, const std::string& /*name*/,
|
|
|
|
const std::string& value, void* addr) {
|
|
|
|
ConfigOptions embedded = opts;
|
|
|
|
embedded.ignore_unsupported_options = true;
|
|
|
|
std::vector<std::shared_ptr<EventListener>> listeners;
|
|
|
|
Status s;
|
|
|
|
for (size_t start = 0, end = 0;
|
|
|
|
s.ok() && start < value.size() && end != std::string::npos;
|
|
|
|
start = end + 1) {
|
|
|
|
std::string token;
|
|
|
|
s = OptionTypeInfo::NextToken(value, ':', start, &end, &token);
|
|
|
|
if (s.ok() && !token.empty()) {
|
|
|
|
std::shared_ptr<EventListener> listener;
|
|
|
|
s = EventListener::CreateFromString(embedded, token, &listener);
|
|
|
|
if (s.ok() && listener != nullptr) {
|
|
|
|
listeners.push_back(listener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s.ok()) { // It worked
|
|
|
|
*(static_cast<std::vector<std::shared_ptr<EventListener>>*>(
|
|
|
|
addr)) = listeners;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
},
|
|
|
|
[](const ConfigOptions& opts, const std::string& /*name*/,
|
|
|
|
const void* addr, std::string* value) {
|
|
|
|
const auto listeners =
|
|
|
|
static_cast<const std::vector<std::shared_ptr<EventListener>>*>(
|
|
|
|
addr);
|
|
|
|
ConfigOptions embedded = opts;
|
|
|
|
embedded.delimiter = ";";
|
|
|
|
int printed = 0;
|
|
|
|
for (const auto& listener : *listeners) {
|
|
|
|
auto id = listener->GetId();
|
|
|
|
if (!id.empty()) {
|
|
|
|
std::string elem_str = listener->ToString(embedded, "");
|
|
|
|
if (printed++ == 0) {
|
|
|
|
value->append("{");
|
|
|
|
} else {
|
|
|
|
value->append(":");
|
|
|
|
}
|
|
|
|
value->append(elem_str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (printed > 0) {
|
|
|
|
value->append("}");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
},
|
|
|
|
nullptr}},
|
2021-10-19 22:53:16 +00:00
|
|
|
{"lowest_used_cache_tier",
|
|
|
|
OptionTypeInfo::Enum<CacheTier>(
|
|
|
|
offsetof(struct ImmutableDBOptions, lowest_used_cache_tier),
|
|
|
|
&cache_tier_string_map, OptionTypeFlags::kNone)},
|
2022-05-16 22:44:59 +00:00
|
|
|
{"enforce_single_del_contracts",
|
|
|
|
{offsetof(struct ImmutableDBOptions, enforce_single_del_contracts),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
Basic RocksDB follower implementation (#12540)
Summary:
A basic implementation of RocksDB follower mode, which opens a remote database (referred to as leader) on a distributed file system by tailing its MANIFEST. It leverages the secondary instance mode, but is different in some key ways -
1. It has its own directory with links to the leader's database
2. Periodically refreshes itself
3. (Future) Snapshot support
4. (Future) Garbage collection of obsolete links
5. (Long term) Memtable replication
There are two main classes implementing this functionality - `DBImplFollower` and `OnDemandFileSystem`. The former is derived from `DBImplSecondary`. Similar to `DBImplSecondary`, it implements recovery and catch up through MANIFEST tailing using the `ReactiveVersionSet`, but does not consider logs. In a future PR, we will implement memtable replication, which will eliminate the need to catch up using logs. In addition, the recovery and catch-up tries to avoid directory listing as repeated metadata operations are expensive.
The second main piece is the `OnDemandFileSystem`, which plugs in as an `Env` for the follower instance and creates the illusion of the follower directory as a clone of the leader directory. It creates links to SSTs on first reference. When the follower tails the MANIFEST and attempts to create a new `Version`, it calls `VerifyFileMetadata` to verify the size of the file, and optionally the unique ID of the file. During this process, links are created which prevent the underlying files from getting deallocated even if the leader deletes the files.
TODOs: Deletion of obsolete links, snapshots, robust checking against misconfigurations, better observability etc.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12540
Reviewed By: jowlyzhang
Differential Revision: D56315718
Pulled By: anand1976
fbshipit-source-id: d19e1aca43a6af4000cb8622a718031b69ebd97b
2024-04-20 02:13:31 +00:00
|
|
|
{"follower_refresh_catchup_period_ms",
|
|
|
|
{offsetof(struct ImmutableDBOptions,
|
|
|
|
follower_refresh_catchup_period_ms),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"follower_catchup_retry_count",
|
|
|
|
{offsetof(struct ImmutableDBOptions, follower_catchup_retry_count),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"follower_catchup_retry_wait_ms",
|
|
|
|
{offsetof(struct ImmutableDBOptions, follower_catchup_retry_wait_ms),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 17:48:46 +00:00
|
|
|
};
|
2020-09-14 23:59:00 +00:00
|
|
|
|
|
|
|
const std::string OptionsHelper::kDBOptionsName = "DBOptions";
|
|
|
|
|
|
|
|
class MutableDBConfigurable : public Configurable {
|
|
|
|
public:
|
2021-10-19 17:42:04 +00:00
|
|
|
explicit MutableDBConfigurable(
|
|
|
|
const MutableDBOptions& mdb,
|
|
|
|
const std::unordered_map<std::string, std::string>* map = nullptr)
|
|
|
|
: mutable_(mdb), opt_map_(map) {
|
2021-04-26 10:12:35 +00:00
|
|
|
RegisterOptions(&mutable_, &db_mutable_options_type_info);
|
2020-09-14 23:59:00 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:42:04 +00:00
|
|
|
bool OptionsAreEqual(const ConfigOptions& config_options,
|
|
|
|
const OptionTypeInfo& opt_info,
|
|
|
|
const std::string& opt_name, const void* const this_ptr,
|
|
|
|
const void* const that_ptr,
|
|
|
|
std::string* mismatch) const override {
|
|
|
|
bool equals = opt_info.AreEqual(config_options, opt_name, this_ptr,
|
|
|
|
that_ptr, mismatch);
|
|
|
|
if (!equals && opt_info.IsByName()) {
|
|
|
|
if (opt_map_ == nullptr) {
|
|
|
|
equals = true;
|
|
|
|
} else {
|
|
|
|
const auto& iter = opt_map_->find(opt_name);
|
|
|
|
if (iter == opt_map_->end()) {
|
|
|
|
equals = true;
|
|
|
|
} else {
|
|
|
|
equals = opt_info.AreEqualByName(config_options, opt_name, this_ptr,
|
|
|
|
iter->second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (equals) { // False alarm, clear mismatch
|
|
|
|
*mismatch = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (equals && opt_info.IsConfigurable() && opt_map_ != nullptr) {
|
|
|
|
const auto* this_config = opt_info.AsRawPointer<Configurable>(this_ptr);
|
|
|
|
if (this_config == nullptr) {
|
|
|
|
const auto& iter = opt_map_->find(opt_name);
|
|
|
|
// If the name exists in the map and is not empty/null,
|
|
|
|
// then the this_config should be set.
|
|
|
|
if (iter != opt_map_->end() && !iter->second.empty() &&
|
|
|
|
iter->second != kNullptrString) {
|
|
|
|
*mismatch = opt_name;
|
|
|
|
equals = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return equals;
|
|
|
|
}
|
|
|
|
|
2020-09-14 23:59:00 +00:00
|
|
|
protected:
|
|
|
|
MutableDBOptions mutable_;
|
2021-10-19 17:42:04 +00:00
|
|
|
const std::unordered_map<std::string, std::string>* opt_map_;
|
2020-09-14 23:59:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DBOptionsConfigurable : public MutableDBConfigurable {
|
|
|
|
public:
|
2021-10-19 17:42:04 +00:00
|
|
|
explicit DBOptionsConfigurable(
|
|
|
|
const DBOptions& opts,
|
|
|
|
const std::unordered_map<std::string, std::string>* map = nullptr)
|
|
|
|
: MutableDBConfigurable(MutableDBOptions(opts), map), db_options_(opts) {
|
2020-09-14 23:59:00 +00:00
|
|
|
// The ImmutableDBOptions currently requires the env to be non-null. Make
|
|
|
|
// sure it is
|
|
|
|
if (opts.env != nullptr) {
|
|
|
|
immutable_ = ImmutableDBOptions(opts);
|
|
|
|
} else {
|
|
|
|
DBOptions copy = opts;
|
|
|
|
copy.env = Env::Default();
|
|
|
|
immutable_ = ImmutableDBOptions(copy);
|
|
|
|
}
|
2021-04-26 10:12:35 +00:00
|
|
|
RegisterOptions(&immutable_, &db_immutable_options_type_info);
|
2020-09-14 23:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Status ConfigureOptions(
|
|
|
|
const ConfigOptions& config_options,
|
|
|
|
const std::unordered_map<std::string, std::string>& opts_map,
|
|
|
|
std::unordered_map<std::string, std::string>* unused) override {
|
2021-02-19 18:25:39 +00:00
|
|
|
Status s = Configurable::ConfigureOptions(config_options, opts_map, unused);
|
2020-09-14 23:59:00 +00:00
|
|
|
if (s.ok()) {
|
|
|
|
db_options_ = BuildDBOptions(immutable_, mutable_);
|
|
|
|
s = PrepareOptions(config_options);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
const void* GetOptionsPtr(const std::string& name) const override {
|
|
|
|
if (name == OptionsHelper::kDBOptionsName) {
|
|
|
|
return &db_options_;
|
|
|
|
} else {
|
|
|
|
return MutableDBConfigurable::GetOptionsPtr(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ImmutableDBOptions immutable_;
|
|
|
|
DBOptions db_options_;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<Configurable> DBOptionsAsConfigurable(
|
|
|
|
const MutableDBOptions& opts) {
|
|
|
|
std::unique_ptr<Configurable> ptr(new MutableDBConfigurable(opts));
|
|
|
|
return ptr;
|
|
|
|
}
|
2021-10-19 17:42:04 +00:00
|
|
|
std::unique_ptr<Configurable> DBOptionsAsConfigurable(
|
|
|
|
const DBOptions& opts,
|
|
|
|
const std::unordered_map<std::string, std::string>* opt_map) {
|
|
|
|
std::unique_ptr<Configurable> ptr(new DBOptionsConfigurable(opts, opt_map));
|
2020-09-14 23:59:00 +00:00
|
|
|
return ptr;
|
|
|
|
}
|
2016-09-23 23:34:04 +00:00
|
|
|
|
|
|
|
ImmutableDBOptions::ImmutableDBOptions() : ImmutableDBOptions(Options()) {}
|
|
|
|
|
|
|
|
ImmutableDBOptions::ImmutableDBOptions(const DBOptions& options)
|
|
|
|
: create_if_missing(options.create_if_missing),
|
|
|
|
create_missing_column_families(options.create_missing_column_families),
|
|
|
|
error_if_exists(options.error_if_exists),
|
|
|
|
paranoid_checks(options.paranoid_checks),
|
2021-05-20 23:06:12 +00:00
|
|
|
flush_verify_memtable_count(options.flush_verify_memtable_count),
|
2023-07-28 16:47:31 +00:00
|
|
|
compaction_verify_record_count(options.compaction_verify_record_count),
|
2020-10-09 23:40:25 +00:00
|
|
|
track_and_verify_wals_in_manifest(
|
|
|
|
options.track_and_verify_wals_in_manifest),
|
2022-05-19 18:04:21 +00:00
|
|
|
verify_sst_unique_id_in_manifest(
|
|
|
|
options.verify_sst_unique_id_in_manifest),
|
2016-09-23 23:34:04 +00:00
|
|
|
env(options.env),
|
|
|
|
rate_limiter(options.rate_limiter),
|
|
|
|
sst_file_manager(options.sst_file_manager),
|
|
|
|
info_log(options.info_log),
|
|
|
|
info_log_level(options.info_log_level),
|
|
|
|
max_file_opening_threads(options.max_file_opening_threads),
|
|
|
|
statistics(options.statistics),
|
|
|
|
use_fsync(options.use_fsync),
|
|
|
|
db_paths(options.db_paths),
|
|
|
|
db_log_dir(options.db_log_dir),
|
|
|
|
wal_dir(options.wal_dir),
|
|
|
|
max_log_file_size(options.max_log_file_size),
|
|
|
|
log_file_time_to_roll(options.log_file_time_to_roll),
|
|
|
|
keep_log_file_num(options.keep_log_file_num),
|
|
|
|
recycle_log_file_num(options.recycle_log_file_num),
|
|
|
|
max_manifest_file_size(options.max_manifest_file_size),
|
|
|
|
table_cache_numshardbits(options.table_cache_numshardbits),
|
2021-04-23 03:42:50 +00:00
|
|
|
WAL_ttl_seconds(options.WAL_ttl_seconds),
|
|
|
|
WAL_size_limit_MB(options.WAL_size_limit_MB),
|
2019-09-12 01:26:22 +00:00
|
|
|
max_write_batch_group_size_bytes(
|
|
|
|
options.max_write_batch_group_size_bytes),
|
2016-09-23 23:34:04 +00:00
|
|
|
manifest_preallocation_size(options.manifest_preallocation_size),
|
|
|
|
allow_mmap_reads(options.allow_mmap_reads),
|
|
|
|
allow_mmap_writes(options.allow_mmap_writes),
|
2016-10-28 17:36:05 +00:00
|
|
|
use_direct_reads(options.use_direct_reads),
|
2017-04-13 20:07:33 +00:00
|
|
|
use_direct_io_for_flush_and_compaction(
|
|
|
|
options.use_direct_io_for_flush_and_compaction),
|
2016-09-23 23:34:04 +00:00
|
|
|
allow_fallocate(options.allow_fallocate),
|
|
|
|
is_fd_close_on_exec(options.is_fd_close_on_exec),
|
|
|
|
advise_random_on_open(options.advise_random_on_open),
|
|
|
|
db_write_buffer_size(options.db_write_buffer_size),
|
|
|
|
write_buffer_manager(options.write_buffer_manager),
|
|
|
|
random_access_max_buffer_size(options.random_access_max_buffer_size),
|
|
|
|
use_adaptive_mutex(options.use_adaptive_mutex),
|
|
|
|
listeners(options.listeners),
|
|
|
|
enable_thread_tracking(options.enable_thread_tracking),
|
2017-05-19 21:24:23 +00:00
|
|
|
enable_pipelined_write(options.enable_pipelined_write),
|
2019-05-14 00:43:47 +00:00
|
|
|
unordered_write(options.unordered_write),
|
2016-09-23 23:34:04 +00:00
|
|
|
allow_concurrent_memtable_write(options.allow_concurrent_memtable_write),
|
|
|
|
enable_write_thread_adaptive_yield(
|
|
|
|
options.enable_write_thread_adaptive_yield),
|
|
|
|
write_thread_max_yield_usec(options.write_thread_max_yield_usec),
|
|
|
|
write_thread_slow_yield_usec(options.write_thread_slow_yield_usec),
|
|
|
|
skip_stats_update_on_db_open(options.skip_stats_update_on_db_open),
|
Add an option to prevent DB::Open() from querying sizes of all sst files (#6353)
Summary:
When paranoid_checks is on, DBImpl::CheckConsistency() iterates over all sst files and calls Env::GetFileSize() for each of them. As far as I could understand, this is pretty arbitrary and doesn't affect correctness - if filesystem doesn't corrupt fsynced files, the file sizes will always match; if it does, it may as well corrupt contents as well as sizes, and rocksdb doesn't check contents on open.
If there are thousands of sst files, getting all their sizes takes a while. If, on top of that, Env is overridden to use some remote storage instead of local filesystem, it can be *really* slow and overload the remote storage service. This PR adds an option to not do GetFileSize(); instead it does GetChildren() for parent directory to check that all the expected sst files are at least present, but doesn't check their sizes.
We can't just disable paranoid_checks instead because paranoid_checks do a few other important things: make the DB read-only on write errors, print error messages on read errors, etc.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6353
Test Plan: ran the added sanity check unit test. Will try it out in a LogDevice test cluster where the GetFileSize() calls are causing a lot of trouble.
Differential Revision: D19656425
Pulled By: al13n321
fbshipit-source-id: c2c421b367633033760d1f56747bad206d1fbf82
2020-02-04 09:24:29 +00:00
|
|
|
skip_checking_sst_file_sizes_on_db_open(
|
|
|
|
options.skip_checking_sst_file_sizes_on_db_open),
|
2016-09-23 23:34:04 +00:00
|
|
|
wal_recovery_mode(options.wal_recovery_mode),
|
|
|
|
allow_2pc(options.allow_2pc),
|
|
|
|
row_cache(options.row_cache),
|
|
|
|
wal_filter(options.wal_filter),
|
|
|
|
fail_if_options_file_error(options.fail_if_options_file_error),
|
|
|
|
dump_malloc_stats(options.dump_malloc_stats),
|
2017-05-17 18:32:26 +00:00
|
|
|
avoid_flush_during_recovery(options.avoid_flush_during_recovery),
|
2017-06-24 21:06:43 +00:00
|
|
|
allow_ingest_behind(options.allow_ingest_behind),
|
2017-11-11 01:18:01 +00:00
|
|
|
two_write_queues(options.two_write_queues),
|
2018-11-12 20:22:10 +00:00
|
|
|
manual_wal_flush(options.manual_wal_flush),
|
2022-01-26 21:57:30 +00:00
|
|
|
wal_compression(options.wal_compression),
|
2019-04-02 00:07:38 +00:00
|
|
|
atomic_flush(options.atomic_flush),
|
2019-06-17 22:17:43 +00:00
|
|
|
avoid_unnecessary_blocking_io(options.avoid_unnecessary_blocking_io),
|
2019-07-19 18:54:38 +00:00
|
|
|
persist_stats_to_disk(options.persist_stats_to_disk),
|
2019-09-03 15:50:47 +00:00
|
|
|
write_dbid_to_manifest(options.write_dbid_to_manifest),
|
2020-02-10 23:42:46 +00:00
|
|
|
log_readahead_size(options.log_readahead_size),
|
2020-03-29 22:57:02 +00:00
|
|
|
file_checksum_gen_factory(options.file_checksum_gen_factory),
|
2020-07-15 18:02:44 +00:00
|
|
|
best_efforts_recovery(options.best_efforts_recovery),
|
|
|
|
max_bgerror_resume_count(options.max_bgerror_resume_count),
|
2020-09-30 06:16:12 +00:00
|
|
|
bgerror_resume_retry_interval(options.bgerror_resume_retry_interval),
|
2020-10-19 18:37:05 +00:00
|
|
|
allow_data_in_errors(options.allow_data_in_errors),
|
2021-02-11 06:18:33 +00:00
|
|
|
db_host_id(options.db_host_id),
|
2021-05-20 04:40:43 +00:00
|
|
|
checksum_handoff_file_types(options.checksum_handoff_file_types),
|
2021-10-19 22:53:16 +00:00
|
|
|
lowest_used_cache_tier(options.lowest_used_cache_tier),
|
2022-05-16 22:44:59 +00:00
|
|
|
compaction_service(options.compaction_service),
|
Basic RocksDB follower implementation (#12540)
Summary:
A basic implementation of RocksDB follower mode, which opens a remote database (referred to as leader) on a distributed file system by tailing its MANIFEST. It leverages the secondary instance mode, but is different in some key ways -
1. It has its own directory with links to the leader's database
2. Periodically refreshes itself
3. (Future) Snapshot support
4. (Future) Garbage collection of obsolete links
5. (Long term) Memtable replication
There are two main classes implementing this functionality - `DBImplFollower` and `OnDemandFileSystem`. The former is derived from `DBImplSecondary`. Similar to `DBImplSecondary`, it implements recovery and catch up through MANIFEST tailing using the `ReactiveVersionSet`, but does not consider logs. In a future PR, we will implement memtable replication, which will eliminate the need to catch up using logs. In addition, the recovery and catch-up tries to avoid directory listing as repeated metadata operations are expensive.
The second main piece is the `OnDemandFileSystem`, which plugs in as an `Env` for the follower instance and creates the illusion of the follower directory as a clone of the leader directory. It creates links to SSTs on first reference. When the follower tails the MANIFEST and attempts to create a new `Version`, it calls `VerifyFileMetadata` to verify the size of the file, and optionally the unique ID of the file. During this process, links are created which prevent the underlying files from getting deallocated even if the leader deletes the files.
TODOs: Deletion of obsolete links, snapshots, robust checking against misconfigurations, better observability etc.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12540
Reviewed By: jowlyzhang
Differential Revision: D56315718
Pulled By: anand1976
fbshipit-source-id: d19e1aca43a6af4000cb8622a718031b69ebd97b
2024-04-20 02:13:31 +00:00
|
|
|
enforce_single_del_contracts(options.enforce_single_del_contracts),
|
|
|
|
follower_refresh_catchup_period_ms(
|
|
|
|
options.follower_refresh_catchup_period_ms),
|
|
|
|
follower_catchup_retry_count(options.follower_catchup_retry_count),
|
|
|
|
follower_catchup_retry_wait_ms(options.follower_catchup_retry_wait_ms) {
|
2021-04-23 03:42:50 +00:00
|
|
|
fs = env->GetFileSystem();
|
2022-03-30 21:51:12 +00:00
|
|
|
clock = env->GetSystemClock().get();
|
2021-04-26 19:43:02 +00:00
|
|
|
logger = info_log.get();
|
|
|
|
stats = statistics.get();
|
2016-09-23 23:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImmutableDBOptions::Dump(Logger* log) const {
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.error_if_exists: %d",
|
|
|
|
error_if_exists);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.create_if_missing: %d",
|
|
|
|
create_if_missing);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.paranoid_checks: %d",
|
|
|
|
paranoid_checks);
|
2021-05-20 23:06:12 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.flush_verify_memtable_count: %d",
|
|
|
|
flush_verify_memtable_count);
|
2023-07-28 16:47:31 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.compaction_verify_record_count: %d",
|
|
|
|
compaction_verify_record_count);
|
2020-10-09 23:40:25 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" "
|
|
|
|
"Options.track_and_verify_wals_in_manifest: %d",
|
|
|
|
track_and_verify_wals_in_manifest);
|
2022-05-19 18:04:21 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.verify_sst_unique_id_in_manifest: %d",
|
|
|
|
verify_sst_unique_id_in_manifest);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.env: %p",
|
|
|
|
env);
|
Introduce a new storage specific Env API (#5761)
Summary:
The current Env API encompasses both storage/file operations, as well as OS related operations. Most of the APIs return a Status, which does not have enough metadata about an error, such as whether its retry-able or not, scope (i.e fault domain) of the error etc., that may be required in order to properly handle a storage error. The file APIs also do not provide enough control over the IO SLA, such as timeout, prioritization, hinting about placement and redundancy etc.
This PR separates out the file/storage APIs from Env into a new FileSystem class. The APIs are updated to return an IOStatus with metadata about the error, as well as to take an IOOptions structure as input in order to allow more control over the IO.
The user can set both ```options.env``` and ```options.file_system``` to specify that RocksDB should use the former for OS related operations and the latter for storage operations. Internally, a ```CompositeEnvWrapper``` has been introduced that inherits from ```Env``` and redirects individual methods to either an ```Env``` implementation or the ```FileSystem``` as appropriate. When options are sanitized during ```DB::Open```, ```options.env``` is replaced with a newly allocated ```CompositeEnvWrapper``` instance if both env and file_system have been specified. This way, the rest of the RocksDB code can continue to function as before.
This PR also ports PosixEnv to the new API by splitting it into two - PosixEnv and PosixFileSystem. PosixEnv is defined as a sub-class of CompositeEnvWrapper, and threading/time functions are overridden with Posix specific implementations in order to avoid an extra level of indirection.
The ```CompositeEnvWrapper``` translates ```IOStatus``` return code to ```Status```, and sets the severity to ```kSoftError``` if the io_status is retryable. The error handling code in RocksDB can then recover the DB automatically.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5761
Differential Revision: D18868376
Pulled By: anand1976
fbshipit-source-id: 39efe18a162ea746fabac6360ff529baba48486f
2019-12-13 22:47:08 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.fs: %s",
|
|
|
|
fs->Name());
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.info_log: %p",
|
|
|
|
info_log.get());
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_file_opening_threads: %d",
|
|
|
|
max_file_opening_threads);
|
2017-08-31 23:21:15 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.statistics: %p",
|
2021-05-05 20:59:21 +00:00
|
|
|
stats);
|
2023-09-15 17:37:25 +00:00
|
|
|
if (stats) {
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.statistics stats level: %u",
|
|
|
|
stats->get_stats_level());
|
|
|
|
}
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.use_fsync: %d",
|
|
|
|
use_fsync);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.max_log_file_size: %" ROCKSDB_PRIszt,
|
|
|
|
max_log_file_size);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.max_manifest_file_size: %" PRIu64,
|
|
|
|
max_manifest_file_size);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.log_file_time_to_roll: %" ROCKSDB_PRIszt,
|
|
|
|
log_file_time_to_roll);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.keep_log_file_num: %" ROCKSDB_PRIszt,
|
|
|
|
keep_log_file_num);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.recycle_log_file_num: %" ROCKSDB_PRIszt,
|
|
|
|
recycle_log_file_num);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.allow_fallocate: %d",
|
|
|
|
allow_fallocate);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.allow_mmap_reads: %d",
|
|
|
|
allow_mmap_reads);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.allow_mmap_writes: %d",
|
|
|
|
allow_mmap_writes);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.use_direct_reads: %d",
|
|
|
|
use_direct_reads);
|
2017-04-13 20:07:33 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" "
|
|
|
|
"Options.use_direct_io_for_flush_and_compaction: %d",
|
|
|
|
use_direct_io_for_flush_and_compaction);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.create_missing_column_families: %d",
|
|
|
|
create_missing_column_families);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.db_log_dir: %s",
|
|
|
|
db_log_dir.c_str());
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.wal_dir: %s",
|
|
|
|
wal_dir.c_str());
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.table_cache_numshardbits: %d",
|
|
|
|
table_cache_numshardbits);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.WAL_ttl_seconds: %" PRIu64,
|
2021-04-23 03:42:50 +00:00
|
|
|
WAL_ttl_seconds);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.WAL_size_limit_MB: %" PRIu64,
|
2021-04-23 03:42:50 +00:00
|
|
|
WAL_size_limit_MB);
|
2019-09-12 01:26:22 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" "
|
|
|
|
"Options.max_write_batch_group_size_bytes: %" PRIu64,
|
|
|
|
max_write_batch_group_size_bytes);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.manifest_preallocation_size: %" ROCKSDB_PRIszt,
|
|
|
|
manifest_preallocation_size);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.is_fd_close_on_exec: %d",
|
|
|
|
is_fd_close_on_exec);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.advise_random_on_open: %d",
|
|
|
|
advise_random_on_open);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.db_write_buffer_size: %" ROCKSDB_PRIszt,
|
|
|
|
db_write_buffer_size);
|
2017-07-18 19:40:17 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.write_buffer_manager: %p",
|
|
|
|
write_buffer_manager.get());
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.random_access_max_buffer_size: %" ROCKSDB_PRIszt,
|
|
|
|
random_access_max_buffer_size);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.use_adaptive_mutex: %d",
|
|
|
|
use_adaptive_mutex);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.rate_limiter: %p",
|
|
|
|
rate_limiter.get());
|
2016-09-23 23:34:04 +00:00
|
|
|
Header(
|
|
|
|
log, " Options.sst_file_manager.rate_bytes_per_sec: %" PRIi64,
|
|
|
|
sst_file_manager ? sst_file_manager->GetDeleteRateBytesPerSecond() : 0);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.wal_recovery_mode: %d",
|
2019-04-04 19:05:42 +00:00
|
|
|
static_cast<int>(wal_recovery_mode));
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.enable_thread_tracking: %d",
|
|
|
|
enable_thread_tracking);
|
2017-05-19 21:24:23 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.enable_pipelined_write: %d",
|
|
|
|
enable_pipelined_write);
|
2019-05-14 00:43:47 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.unordered_write: %d",
|
|
|
|
unordered_write);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.allow_concurrent_memtable_write: %d",
|
|
|
|
allow_concurrent_memtable_write);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.enable_write_thread_adaptive_yield: %d",
|
|
|
|
enable_write_thread_adaptive_yield);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.write_thread_max_yield_usec: %" PRIu64,
|
|
|
|
write_thread_max_yield_usec);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.write_thread_slow_yield_usec: %" PRIu64,
|
|
|
|
write_thread_slow_yield_usec);
|
2016-09-23 23:34:04 +00:00
|
|
|
if (row_cache) {
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(
|
2019-04-04 19:05:42 +00:00
|
|
|
log,
|
|
|
|
" Options.row_cache: %" ROCKSDB_PRIszt,
|
2017-03-16 02:22:52 +00:00
|
|
|
row_cache->GetCapacity());
|
2016-09-23 23:34:04 +00:00
|
|
|
} else {
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.row_cache: None");
|
2016-09-23 23:34:04 +00:00
|
|
|
}
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.wal_filter: %s",
|
|
|
|
wal_filter ? wal_filter->Name() : "None");
|
2017-05-17 18:32:26 +00:00
|
|
|
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.avoid_flush_during_recovery: %d",
|
|
|
|
avoid_flush_during_recovery);
|
2017-05-17 18:32:26 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.allow_ingest_behind: %d",
|
|
|
|
allow_ingest_behind);
|
2017-11-11 01:18:01 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.two_write_queues: %d",
|
|
|
|
two_write_queues);
|
2017-06-24 21:06:43 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.manual_wal_flush: %d",
|
|
|
|
manual_wal_flush);
|
2022-01-26 21:57:30 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.wal_compression: %d",
|
|
|
|
wal_compression);
|
2019-04-02 00:07:38 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.atomic_flush: %d", atomic_flush);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.avoid_unnecessary_blocking_io: %d",
|
|
|
|
avoid_unnecessary_blocking_io);
|
2019-06-17 22:17:43 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.persist_stats_to_disk: %u",
|
|
|
|
persist_stats_to_disk);
|
2019-09-03 15:50:47 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.write_dbid_to_manifest: %d",
|
|
|
|
write_dbid_to_manifest);
|
2019-07-19 18:54:38 +00:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.log_readahead_size: %" ROCKSDB_PRIszt,
|
|
|
|
log_readahead_size);
|
2020-03-29 22:57:02 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.file_checksum_gen_factory: %s",
|
2020-06-08 04:54:54 +00:00
|
|
|
file_checksum_gen_factory ? file_checksum_gen_factory->Name()
|
|
|
|
: kUnknownFileChecksumFuncName);
|
2020-03-21 02:17:54 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.best_efforts_recovery: %d",
|
|
|
|
static_cast<int>(best_efforts_recovery));
|
2020-07-15 18:02:44 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_bgerror_resume_count: %d",
|
|
|
|
max_bgerror_resume_count);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.bgerror_resume_retry_interval: %" PRIu64,
|
|
|
|
bgerror_resume_retry_interval);
|
2020-09-30 06:16:12 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.allow_data_in_errors: %d",
|
|
|
|
allow_data_in_errors);
|
2020-10-19 18:37:05 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.db_host_id: %s",
|
|
|
|
db_host_id.c_str());
|
2022-05-16 22:44:59 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.enforce_single_del_contracts: %s",
|
|
|
|
enforce_single_del_contracts ? "true" : "false");
|
2016-09-23 23:34:04 +00:00
|
|
|
}
|
|
|
|
|
2021-07-30 19:15:04 +00:00
|
|
|
bool ImmutableDBOptions::IsWalDirSameAsDBPath() const {
|
|
|
|
assert(!db_paths.empty());
|
|
|
|
return IsWalDirSameAsDBPath(db_paths[0].path);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImmutableDBOptions::IsWalDirSameAsDBPath(
|
|
|
|
const std::string& db_path) const {
|
|
|
|
bool same = wal_dir.empty();
|
|
|
|
if (!same) {
|
|
|
|
Status s = env->AreFilesSame(wal_dir, db_path, &same);
|
|
|
|
if (s.IsNotSupported()) {
|
|
|
|
same = wal_dir == db_path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return same;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& ImmutableDBOptions::GetWalDir() const {
|
|
|
|
if (wal_dir.empty()) {
|
|
|
|
assert(!db_paths.empty());
|
|
|
|
return db_paths[0].path;
|
|
|
|
} else {
|
|
|
|
return wal_dir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& ImmutableDBOptions::GetWalDir(
|
|
|
|
const std::string& path) const {
|
|
|
|
if (wal_dir.empty()) {
|
|
|
|
return path;
|
|
|
|
} else {
|
|
|
|
return wal_dir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-14 19:25:39 +00:00
|
|
|
MutableDBOptions::MutableDBOptions()
|
2017-05-24 18:25:38 +00:00
|
|
|
: max_background_jobs(2),
|
|
|
|
max_background_compactions(-1),
|
2020-07-23 01:31:25 +00:00
|
|
|
max_subcompactions(0),
|
2016-11-12 23:43:33 +00:00
|
|
|
avoid_flush_during_shutdown(false),
|
2024-05-21 00:33:43 +00:00
|
|
|
avoid_sync_during_shutdown(true),
|
2017-10-31 20:49:25 +00:00
|
|
|
writable_file_max_buffer_size(1024 * 1024),
|
2016-11-15 06:45:16 +00:00
|
|
|
delayed_write_rate(2 * 1024U * 1024U),
|
2016-12-05 22:09:35 +00:00
|
|
|
max_total_wal_size(0),
|
2017-03-21 05:50:56 +00:00
|
|
|
delete_obsolete_files_period_micros(6ULL * 60 * 60 * 1000000),
|
2017-05-04 03:46:17 +00:00
|
|
|
stats_dump_period_sec(600),
|
2019-02-20 23:46:59 +00:00
|
|
|
stats_persist_period_sec(600),
|
|
|
|
stats_history_buffer_size(1024 * 1024),
|
2017-10-27 03:54:48 +00:00
|
|
|
max_open_files(-1),
|
|
|
|
bytes_per_sync(0),
|
2017-11-17 01:46:43 +00:00
|
|
|
wal_bytes_per_sync(0),
|
Optionally wait on bytes_per_sync to smooth I/O (#5183)
Summary:
The existing implementation does not guarantee bytes reach disk every `bytes_per_sync` when writing SST files, or every `wal_bytes_per_sync` when writing WALs. This can cause confusing behavior for users who enable this feature to avoid large syncs during flush and compaction, but then end up hitting them anyways.
My understanding of the existing behavior is we used `sync_file_range` with `SYNC_FILE_RANGE_WRITE` to submit ranges for async writeback, such that we could continue processing the next range of bytes while that I/O is happening. I believe we can preserve that benefit while also limiting how far the processing can get ahead of the I/O, which prevents huge syncs from happening when the file finishes.
Consider this `sync_file_range` usage: `sync_file_range(fd_, 0, static_cast<off_t>(offset + nbytes), SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE)`. Expanding the range to start at 0 and adding the `SYNC_FILE_RANGE_WAIT_BEFORE` flag causes any pending writeback (like from a previous call to `sync_file_range`) to finish before it proceeds to submit the latest `nbytes` for writeback. The latest `nbytes` are still written back asynchronously, unless processing exceeds I/O speed, in which case the following `sync_file_range` will need to wait on it.
There is a second change in this PR to use `fdatasync` when `sync_file_range` is unavailable (determined statically) or has some known problem with the underlying filesystem (determined dynamically).
The above two changes only apply when the user enables a new option, `strict_bytes_per_sync`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5183
Differential Revision: D14953553
Pulled By: siying
fbshipit-source-id: 445c3862e019fb7b470f9c7f314fc231b62706e9
2019-04-22 18:48:45 +00:00
|
|
|
strict_bytes_per_sync(false),
|
2020-04-20 23:17:25 +00:00
|
|
|
compaction_readahead_size(0),
|
2023-12-01 19:10:30 +00:00
|
|
|
max_background_flushes(-1) {}
|
2016-10-14 19:25:39 +00:00
|
|
|
|
|
|
|
MutableDBOptions::MutableDBOptions(const DBOptions& options)
|
2017-05-24 18:25:38 +00:00
|
|
|
: max_background_jobs(options.max_background_jobs),
|
2016-11-02 22:22:13 +00:00
|
|
|
max_background_compactions(options.max_background_compactions),
|
2020-07-23 01:31:25 +00:00
|
|
|
max_subcompactions(options.max_subcompactions),
|
2016-11-12 23:43:33 +00:00
|
|
|
avoid_flush_during_shutdown(options.avoid_flush_during_shutdown),
|
2024-05-21 00:33:43 +00:00
|
|
|
avoid_sync_during_shutdown(options.avoid_sync_during_shutdown),
|
2017-10-31 20:49:25 +00:00
|
|
|
writable_file_max_buffer_size(options.writable_file_max_buffer_size),
|
2016-11-15 06:45:16 +00:00
|
|
|
delayed_write_rate(options.delayed_write_rate),
|
2016-12-05 22:09:35 +00:00
|
|
|
max_total_wal_size(options.max_total_wal_size),
|
|
|
|
delete_obsolete_files_period_micros(
|
2017-03-21 05:50:56 +00:00
|
|
|
options.delete_obsolete_files_period_micros),
|
2017-05-04 03:46:17 +00:00
|
|
|
stats_dump_period_sec(options.stats_dump_period_sec),
|
2019-02-20 23:46:59 +00:00
|
|
|
stats_persist_period_sec(options.stats_persist_period_sec),
|
|
|
|
stats_history_buffer_size(options.stats_history_buffer_size),
|
2017-09-28 00:37:08 +00:00
|
|
|
max_open_files(options.max_open_files),
|
|
|
|
bytes_per_sync(options.bytes_per_sync),
|
2017-11-17 01:46:43 +00:00
|
|
|
wal_bytes_per_sync(options.wal_bytes_per_sync),
|
Optionally wait on bytes_per_sync to smooth I/O (#5183)
Summary:
The existing implementation does not guarantee bytes reach disk every `bytes_per_sync` when writing SST files, or every `wal_bytes_per_sync` when writing WALs. This can cause confusing behavior for users who enable this feature to avoid large syncs during flush and compaction, but then end up hitting them anyways.
My understanding of the existing behavior is we used `sync_file_range` with `SYNC_FILE_RANGE_WRITE` to submit ranges for async writeback, such that we could continue processing the next range of bytes while that I/O is happening. I believe we can preserve that benefit while also limiting how far the processing can get ahead of the I/O, which prevents huge syncs from happening when the file finishes.
Consider this `sync_file_range` usage: `sync_file_range(fd_, 0, static_cast<off_t>(offset + nbytes), SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE)`. Expanding the range to start at 0 and adding the `SYNC_FILE_RANGE_WAIT_BEFORE` flag causes any pending writeback (like from a previous call to `sync_file_range`) to finish before it proceeds to submit the latest `nbytes` for writeback. The latest `nbytes` are still written back asynchronously, unless processing exceeds I/O speed, in which case the following `sync_file_range` will need to wait on it.
There is a second change in this PR to use `fdatasync` when `sync_file_range` is unavailable (determined statically) or has some known problem with the underlying filesystem (determined dynamically).
The above two changes only apply when the user enables a new option, `strict_bytes_per_sync`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5183
Differential Revision: D14953553
Pulled By: siying
fbshipit-source-id: 445c3862e019fb7b470f9c7f314fc231b62706e9
2019-04-22 18:48:45 +00:00
|
|
|
strict_bytes_per_sync(options.strict_bytes_per_sync),
|
2020-04-20 23:17:25 +00:00
|
|
|
compaction_readahead_size(options.compaction_readahead_size),
|
Offpeak in db option (#11893)
Summary:
RocksDB's primary function is to facilitate read and write operations. Compactions, while essential for minimizing read amplifications and optimizing storage, can sometimes compete with these primary tasks. Especially during periods of high read/write traffic, it's vital to ensure that primary operations receive priority, avoiding any potential disruptions or slowdowns. Conversely, during off-peak times when traffic is minimal, it's an opportune moment to tackle low-priority tasks like TTL based compactions, optimizing resource usage.
In this PR, we are incorporating the concept of off-peak time into RocksDB by introducing `daily_offpeak_time_utc` within the DBOptions. This setting is formatted as "HH:mm-HH:mm" where the first one before "-" is the start time and the second one is the end time, inclusive. It will be later used for resource optimization in subsequent PRs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11893
Test Plan:
- New Unit Test Added - `DBOptionsTest::OffPeakTimes`
- Existing Unit Test Updated - `OptionsTest`, `OptionsSettableTest`
Reviewed By: pdillinger
Differential Revision: D49714553
Pulled By: jaykorean
fbshipit-source-id: fef51ea7c0fede6431c715bff116ddbb567c8752
2023-09-29 20:03:39 +00:00
|
|
|
max_background_flushes(options.max_background_flushes),
|
|
|
|
daily_offpeak_time_utc(options.daily_offpeak_time_utc) {}
|
2016-09-23 23:34:04 +00:00
|
|
|
|
2016-10-14 19:25:39 +00:00
|
|
|
void MutableDBOptions::Dump(Logger* log) const {
|
2017-05-24 18:25:38 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_background_jobs: %d",
|
|
|
|
max_background_jobs);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_background_compactions: %d",
|
|
|
|
max_background_compactions);
|
2020-07-23 01:31:25 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_subcompactions: %" PRIu32,
|
|
|
|
max_subcompactions);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.avoid_flush_during_shutdown: %d",
|
|
|
|
avoid_flush_during_shutdown);
|
2024-05-21 00:33:43 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.avoid_sync_during_shutdown: %d",
|
|
|
|
avoid_sync_during_shutdown);
|
2017-10-31 20:49:25 +00:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.writable_file_max_buffer_size: %" ROCKSDB_PRIszt,
|
|
|
|
writable_file_max_buffer_size);
|
2017-03-16 02:22:52 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.delayed_write_rate : %" PRIu64,
|
|
|
|
delayed_write_rate);
|
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_total_wal_size: %" PRIu64,
|
|
|
|
max_total_wal_size);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.delete_obsolete_files_period_micros: %" PRIu64,
|
|
|
|
delete_obsolete_files_period_micros);
|
2017-03-21 05:50:56 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.stats_dump_period_sec: %u",
|
|
|
|
stats_dump_period_sec);
|
2019-02-20 23:46:59 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.stats_persist_period_sec: %d",
|
|
|
|
stats_persist_period_sec);
|
2019-04-04 19:05:42 +00:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log,
|
|
|
|
" Options.stats_history_buffer_size: %" ROCKSDB_PRIszt,
|
|
|
|
stats_history_buffer_size);
|
2017-05-04 03:46:17 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_open_files: %d",
|
|
|
|
max_open_files);
|
2017-09-28 00:37:08 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.bytes_per_sync: %" PRIu64,
|
|
|
|
bytes_per_sync);
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.wal_bytes_per_sync: %" PRIu64,
|
|
|
|
wal_bytes_per_sync);
|
Optionally wait on bytes_per_sync to smooth I/O (#5183)
Summary:
The existing implementation does not guarantee bytes reach disk every `bytes_per_sync` when writing SST files, or every `wal_bytes_per_sync` when writing WALs. This can cause confusing behavior for users who enable this feature to avoid large syncs during flush and compaction, but then end up hitting them anyways.
My understanding of the existing behavior is we used `sync_file_range` with `SYNC_FILE_RANGE_WRITE` to submit ranges for async writeback, such that we could continue processing the next range of bytes while that I/O is happening. I believe we can preserve that benefit while also limiting how far the processing can get ahead of the I/O, which prevents huge syncs from happening when the file finishes.
Consider this `sync_file_range` usage: `sync_file_range(fd_, 0, static_cast<off_t>(offset + nbytes), SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE)`. Expanding the range to start at 0 and adding the `SYNC_FILE_RANGE_WAIT_BEFORE` flag causes any pending writeback (like from a previous call to `sync_file_range`) to finish before it proceeds to submit the latest `nbytes` for writeback. The latest `nbytes` are still written back asynchronously, unless processing exceeds I/O speed, in which case the following `sync_file_range` will need to wait on it.
There is a second change in this PR to use `fdatasync` when `sync_file_range` is unavailable (determined statically) or has some known problem with the underlying filesystem (determined dynamically).
The above two changes only apply when the user enables a new option, `strict_bytes_per_sync`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5183
Differential Revision: D14953553
Pulled By: siying
fbshipit-source-id: 445c3862e019fb7b470f9c7f314fc231b62706e9
2019-04-22 18:48:45 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.strict_bytes_per_sync: %d",
|
|
|
|
strict_bytes_per_sync);
|
2017-11-17 01:46:43 +00:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.compaction_readahead_size: %" ROCKSDB_PRIszt,
|
|
|
|
compaction_readahead_size);
|
2020-04-20 23:17:25 +00:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.max_background_flushes: %d",
|
|
|
|
max_background_flushes);
|
Offpeak in db option (#11893)
Summary:
RocksDB's primary function is to facilitate read and write operations. Compactions, while essential for minimizing read amplifications and optimizing storage, can sometimes compete with these primary tasks. Especially during periods of high read/write traffic, it's vital to ensure that primary operations receive priority, avoiding any potential disruptions or slowdowns. Conversely, during off-peak times when traffic is minimal, it's an opportune moment to tackle low-priority tasks like TTL based compactions, optimizing resource usage.
In this PR, we are incorporating the concept of off-peak time into RocksDB by introducing `daily_offpeak_time_utc` within the DBOptions. This setting is formatted as "HH:mm-HH:mm" where the first one before "-" is the start time and the second one is the end time, inclusive. It will be later used for resource optimization in subsequent PRs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11893
Test Plan:
- New Unit Test Added - `DBOptionsTest::OffPeakTimes`
- Existing Unit Test Updated - `OptionsTest`, `OptionsSettableTest`
Reviewed By: pdillinger
Differential Revision: D49714553
Pulled By: jaykorean
fbshipit-source-id: fef51ea7c0fede6431c715bff116ddbb567c8752
2023-09-29 20:03:39 +00:00
|
|
|
ROCKS_LOG_HEADER(log, "Options.daily_offpeak_time_utc: %s",
|
|
|
|
daily_offpeak_time_utc.c_str());
|
|
|
|
}
|
|
|
|
|
2021-05-11 23:14:33 +00:00
|
|
|
Status GetMutableDBOptionsFromStrings(
|
|
|
|
const MutableDBOptions& base_options,
|
|
|
|
const std::unordered_map<std::string, std::string>& options_map,
|
|
|
|
MutableDBOptions* new_options) {
|
|
|
|
assert(new_options);
|
|
|
|
*new_options = base_options;
|
|
|
|
ConfigOptions config_options;
|
|
|
|
Status s = OptionTypeInfo::ParseType(
|
|
|
|
config_options, options_map, db_mutable_options_type_info, new_options);
|
|
|
|
if (!s.ok()) {
|
|
|
|
*new_options = base_options;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2021-07-21 20:44:39 +00:00
|
|
|
bool MutableDBOptionsAreEqual(const MutableDBOptions& this_options,
|
|
|
|
const MutableDBOptions& that_options) {
|
|
|
|
ConfigOptions config_options;
|
|
|
|
std::string mismatch;
|
|
|
|
return OptionTypeInfo::StructsAreEqual(
|
|
|
|
config_options, "MutableDBOptions", &db_mutable_options_type_info,
|
|
|
|
"MutableDBOptions", &this_options, &that_options, &mismatch);
|
|
|
|
}
|
|
|
|
|
2021-05-11 23:14:33 +00:00
|
|
|
Status GetStringFromMutableDBOptions(const ConfigOptions& config_options,
|
|
|
|
const MutableDBOptions& mutable_opts,
|
|
|
|
std::string* opt_string) {
|
|
|
|
return OptionTypeInfo::SerializeType(
|
|
|
|
config_options, db_mutable_options_type_info, &mutable_opts, opt_string);
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|