2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02: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).
|
2014-10-02 01:19:16 +02:00
|
|
|
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "options/cf_options.h"
|
2015-09-11 23:31:23 +02:00
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
#include <cassert>
|
2019-09-20 21:00:55 +02:00
|
|
|
#include <cinttypes>
|
2016-09-14 06:11:59 +02:00
|
|
|
#include <limits>
|
2014-10-17 02:22:28 +02:00
|
|
|
#include <string>
|
2020-04-03 19:48:46 +02:00
|
|
|
|
2020-09-15 01:59:00 +02:00
|
|
|
#include "options/configurable_helper.h"
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "options/db_options.h"
|
2020-04-03 19:48:46 +02:00
|
|
|
#include "options/options_helper.h"
|
2020-09-15 01:59:00 +02:00
|
|
|
#include "options/options_parser.h"
|
2015-07-11 18:54:33 +02:00
|
|
|
#include "port/port.h"
|
2019-09-20 21:00:55 +02:00
|
|
|
#include "rocksdb/concurrent_task_limiter.h"
|
2020-09-15 01:59:00 +02:00
|
|
|
#include "rocksdb/configurable.h"
|
2020-04-03 19:48:46 +02:00
|
|
|
#include "rocksdb/convenience.h"
|
2014-10-17 02:22:28 +02: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 23:47:08 +01:00
|
|
|
#include "rocksdb/file_system.h"
|
2020-04-03 19:48:46 +02:00
|
|
|
#include "rocksdb/merge_operator.h"
|
2014-10-02 01:19:16 +02:00
|
|
|
#include "rocksdb/options.h"
|
2020-09-15 01:59:00 +02:00
|
|
|
#include "rocksdb/table.h"
|
2020-04-03 19:48:46 +02:00
|
|
|
#include "rocksdb/utilities/object_registry.h"
|
2020-09-15 01:59:00 +02:00
|
|
|
#include "rocksdb/utilities/options_type.h"
|
2020-04-03 19:48:46 +02:00
|
|
|
#include "util/cast_util.h"
|
2014-10-02 01:19:16 +02:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2020-04-03 19:48:46 +02:00
|
|
|
// offset_of is used to get the offset of a class data member
|
|
|
|
// ex: offset_of(&ColumnFamilyOptions::num_levels)
|
|
|
|
// This call will return the offset of num_levels in ColumnFamilyOptions class
|
|
|
|
//
|
|
|
|
// This is the same as offsetof() but allow us to work with non standard-layout
|
|
|
|
// classes and structures
|
|
|
|
// refs:
|
|
|
|
// http://en.cppreference.com/w/cpp/concept/StandardLayoutType
|
|
|
|
// https://gist.github.com/graphitemaster/494f21190bb2c63c5516
|
|
|
|
#ifndef ROCKSDB_LITE
|
2020-09-15 01:59:00 +02:00
|
|
|
static ColumnFamilyOptions dummy_cf_options;
|
2020-04-03 19:48:46 +02:00
|
|
|
template <typename T1>
|
|
|
|
int offset_of(T1 ColumnFamilyOptions::*member) {
|
2020-09-15 01:59:00 +02:00
|
|
|
return int(size_t(&(dummy_cf_options.*member)) - size_t(&dummy_cf_options));
|
2020-04-03 19:48:46 +02:00
|
|
|
}
|
|
|
|
template <typename T1>
|
|
|
|
int offset_of(T1 AdvancedColumnFamilyOptions::*member) {
|
2020-09-15 01:59:00 +02:00
|
|
|
return int(size_t(&(dummy_cf_options.*member)) - size_t(&dummy_cf_options));
|
2020-04-03 19:48:46 +02:00
|
|
|
}
|
|
|
|
|
2020-04-29 03:02:11 +02:00
|
|
|
static Status ParseCompressionOptions(const std::string& value,
|
|
|
|
const std::string& name,
|
|
|
|
CompressionOptions& compression_opts) {
|
|
|
|
size_t start = 0;
|
|
|
|
size_t end = value.find(':');
|
|
|
|
if (end == std::string::npos) {
|
|
|
|
return Status::InvalidArgument("unable to parse the specified CF option " +
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
compression_opts.window_bits = ParseInt(value.substr(start, end - start));
|
|
|
|
start = end + 1;
|
|
|
|
end = value.find(':', start);
|
|
|
|
if (end == std::string::npos) {
|
|
|
|
return Status::InvalidArgument("unable to parse the specified CF option " +
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
compression_opts.level = ParseInt(value.substr(start, end - start));
|
|
|
|
start = end + 1;
|
|
|
|
if (start >= value.size()) {
|
|
|
|
return Status::InvalidArgument("unable to parse the specified CF option " +
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
end = value.find(':', start);
|
|
|
|
compression_opts.strategy =
|
|
|
|
ParseInt(value.substr(start, value.size() - start));
|
|
|
|
// max_dict_bytes is optional for backwards compatibility
|
|
|
|
if (end != std::string::npos) {
|
|
|
|
start = end + 1;
|
|
|
|
if (start >= value.size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"unable to parse the specified CF option " + name);
|
|
|
|
}
|
|
|
|
compression_opts.max_dict_bytes =
|
|
|
|
ParseInt(value.substr(start, value.size() - start));
|
|
|
|
end = value.find(':', start);
|
|
|
|
}
|
|
|
|
// zstd_max_train_bytes is optional for backwards compatibility
|
|
|
|
if (end != std::string::npos) {
|
|
|
|
start = end + 1;
|
|
|
|
if (start >= value.size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"unable to parse the specified CF option " + name);
|
|
|
|
}
|
|
|
|
compression_opts.zstd_max_train_bytes =
|
|
|
|
ParseInt(value.substr(start, value.size() - start));
|
|
|
|
end = value.find(':', start);
|
|
|
|
}
|
2020-07-17 04:04:44 +02:00
|
|
|
|
|
|
|
// parallel_threads is optional for backwards compatibility
|
|
|
|
if (end != std::string::npos) {
|
|
|
|
start = end + 1;
|
|
|
|
if (start >= value.size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"unable to parse the specified CF option " + name);
|
|
|
|
}
|
|
|
|
// Since parallel_threads comes before enabled but was added optionally
|
|
|
|
// later, we need to check if this is the final token (meaning it is the
|
|
|
|
// enabled bit), or if there is another token (meaning this one is
|
|
|
|
// parallel_threads)
|
|
|
|
end = value.find(':', start);
|
|
|
|
if (end != std::string::npos) {
|
|
|
|
compression_opts.parallel_threads =
|
|
|
|
ParseInt(value.substr(start, value.size() - start));
|
|
|
|
} else {
|
|
|
|
// parallel_threads is not serialized with this format, but enabled is
|
|
|
|
compression_opts.parallel_threads = CompressionOptions().parallel_threads;
|
|
|
|
compression_opts.enabled =
|
|
|
|
ParseBoolean("", value.substr(start, value.size() - start));
|
|
|
|
}
|
|
|
|
}
|
2020-05-01 01:59:16 +02:00
|
|
|
|
2020-04-29 03:02:11 +02:00
|
|
|
// enabled is optional for backwards compatibility
|
|
|
|
if (end != std::string::npos) {
|
|
|
|
start = end + 1;
|
|
|
|
if (start >= value.size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"unable to parse the specified CF option " + name);
|
|
|
|
}
|
|
|
|
compression_opts.enabled =
|
|
|
|
ParseBoolean("", value.substr(start, value.size() - start));
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string kOptNameBMCompOpts = "bottommost_compression_opts";
|
|
|
|
const std::string kOptNameCompOpts = "compression_opts";
|
2020-04-03 19:48:46 +02:00
|
|
|
|
2020-07-17 04:04:44 +02:00
|
|
|
// OptionTypeInfo map for CompressionOptions
|
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
compression_options_type_info = {
|
|
|
|
{"window_bits",
|
|
|
|
{offsetof(struct CompressionOptions, window_bits), OptionType::kInt,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
{"level",
|
|
|
|
{offsetof(struct CompressionOptions, level), OptionType::kInt,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
{"strategy",
|
|
|
|
{offsetof(struct CompressionOptions, strategy), OptionType::kInt,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
{"max_dict_bytes",
|
|
|
|
{offsetof(struct CompressionOptions, max_dict_bytes), OptionType::kInt,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
{"zstd_max_train_bytes",
|
|
|
|
{offsetof(struct CompressionOptions, zstd_max_train_bytes),
|
|
|
|
OptionType::kUInt32T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
{"parallel_threads",
|
|
|
|
{offsetof(struct CompressionOptions, parallel_threads),
|
|
|
|
OptionType::kUInt32T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
{"enabled",
|
|
|
|
{offsetof(struct CompressionOptions, enabled), OptionType::kBoolean,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
2020-07-17 04:04:44 +02:00
|
|
|
};
|
|
|
|
|
2020-05-21 19:56:40 +02:00
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
fifo_compaction_options_type_info = {
|
|
|
|
{"max_table_files_size",
|
|
|
|
{offsetof(struct CompactionOptionsFIFO, max_table_files_size),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"ttl",
|
|
|
|
{0, OptionType::kUInt64T, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"allow_compaction",
|
|
|
|
{offsetof(struct CompactionOptionsFIFO, allow_compaction),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
};
|
2020-05-21 19:56:40 +02:00
|
|
|
|
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
universal_compaction_options_type_info = {
|
|
|
|
{"size_ratio",
|
|
|
|
{offsetof(class CompactionOptionsUniversal, size_ratio),
|
|
|
|
OptionType::kUInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"min_merge_width",
|
|
|
|
{offsetof(class CompactionOptionsUniversal, min_merge_width),
|
|
|
|
OptionType::kUInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"max_merge_width",
|
|
|
|
{offsetof(class CompactionOptionsUniversal, max_merge_width),
|
|
|
|
OptionType::kUInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"max_size_amplification_percent",
|
|
|
|
{offsetof(class CompactionOptionsUniversal,
|
|
|
|
max_size_amplification_percent),
|
|
|
|
OptionType::kUInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"compression_size_percent",
|
|
|
|
{offsetof(class CompactionOptionsUniversal, compression_size_percent),
|
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"stop_style",
|
|
|
|
{offsetof(class CompactionOptionsUniversal, stop_style),
|
|
|
|
OptionType::kCompactionStopStyle, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-05-21 19:56:40 +02:00
|
|
|
{"allow_trivial_move",
|
|
|
|
{offsetof(class CompactionOptionsUniversal, allow_trivial_move),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}}};
|
2020-05-21 19:56:40 +02:00
|
|
|
|
2020-09-15 01:59:00 +02:00
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
cf_mutable_options_type_info = {
|
2020-04-03 19:48:46 +02:00
|
|
|
{"report_bg_io_stats",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, report_bg_io_stats),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"disable_auto_compactions",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, disable_auto_compactions),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"filter_deletes",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-10-01 19:08:52 +02:00
|
|
|
{"check_flush_compaction_key_order",
|
|
|
|
{offsetof(struct MutableCFOptions, check_flush_compaction_key_order),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"paranoid_file_checks",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, paranoid_file_checks),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"verify_checksums_in_compaction",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"soft_pending_compaction_bytes_limit",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions,
|
|
|
|
soft_pending_compaction_bytes_limit),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"hard_pending_compaction_bytes_limit",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions,
|
|
|
|
hard_pending_compaction_bytes_limit),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"hard_rate_limit",
|
|
|
|
{0, OptionType::kDouble, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"soft_rate_limit",
|
|
|
|
{0, OptionType::kDouble, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_compaction_bytes",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, max_compaction_bytes),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"expanded_compaction_factor",
|
|
|
|
{0, OptionType::kInt, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"level0_file_num_compaction_trigger",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, level0_file_num_compaction_trigger),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"level0_slowdown_writes_trigger",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, level0_slowdown_writes_trigger),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"level0_stop_writes_trigger",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, level0_stop_writes_trigger),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_grandparent_overlap_factor",
|
|
|
|
{0, OptionType::kInt, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_write_buffer_number",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, max_write_buffer_number),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"source_compaction_factor",
|
|
|
|
{0, OptionType::kInt, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"target_file_size_multiplier",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, target_file_size_multiplier),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"arena_block_size",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, arena_block_size),
|
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"inplace_update_num_locks",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, inplace_update_num_locks),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_successive_merges",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, max_successive_merges),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_huge_page_size",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, memtable_huge_page_size),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_prefix_bloom_huge_page_tlb_size",
|
|
|
|
{0, OptionType::kSizeT, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"write_buffer_size",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, write_buffer_size),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kSizeT, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_prefix_bloom_bits",
|
|
|
|
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_prefix_bloom_size_ratio",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, memtable_prefix_bloom_size_ratio),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kDouble, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_prefix_bloom_probes",
|
|
|
|
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_whole_key_filtering",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, memtable_whole_key_filtering),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"min_partial_merge_operands",
|
|
|
|
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_bytes_for_level_base",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, max_bytes_for_level_base),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"snap_refresh_nanos",
|
|
|
|
{0, OptionType::kUInt64T, OptionVerificationType::kDeprecated,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_bytes_for_level_multiplier",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, max_bytes_for_level_multiplier),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kDouble, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_bytes_for_level_multiplier_additional",
|
2020-06-03 21:19:54 +02:00
|
|
|
OptionTypeInfo::Vector<int>(
|
|
|
|
offsetof(struct MutableCFOptions,
|
|
|
|
max_bytes_for_level_multiplier_additional),
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable,
|
|
|
|
{0, OptionType::kInt})},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"max_sequential_skip_in_iterations",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, max_sequential_skip_in_iterations),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"target_file_size_base",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, target_file_size_base),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"compression",
|
2020-09-15 01:59:00 +02:00
|
|
|
{offsetof(struct MutableCFOptions, compression),
|
|
|
|
OptionType::kCompressionType, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"prefix_extractor",
|
|
|
|
{offsetof(struct MutableCFOptions, prefix_extractor),
|
|
|
|
OptionType::kSliceTransform, OptionVerificationType::kByNameAllowNull,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"compaction_options_fifo",
|
|
|
|
OptionTypeInfo::Struct(
|
|
|
|
"compaction_options_fifo", &fifo_compaction_options_type_info,
|
|
|
|
offsetof(struct MutableCFOptions, compaction_options_fifo),
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable,
|
|
|
|
[](const ConfigOptions& opts, const std::string& name,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
// This is to handle backward compatibility, where
|
|
|
|
// compaction_options_fifo could be assigned a single scalar
|
|
|
|
// value, say, like "23", which would be assigned to
|
|
|
|
// max_table_files_size.
|
|
|
|
if (name == "compaction_options_fifo" &&
|
|
|
|
value.find("=") == std::string::npos) {
|
|
|
|
// Old format. Parse just a single uint64_t value.
|
|
|
|
auto options = reinterpret_cast<CompactionOptionsFIFO*>(addr);
|
|
|
|
options->max_table_files_size = ParseUint64(value);
|
|
|
|
return Status::OK();
|
|
|
|
} else {
|
|
|
|
return OptionTypeInfo::ParseStruct(
|
|
|
|
opts, "compaction_options_fifo",
|
|
|
|
&fifo_compaction_options_type_info, name, value, addr);
|
|
|
|
}
|
|
|
|
})},
|
|
|
|
{"compaction_options_universal",
|
|
|
|
OptionTypeInfo::Struct(
|
|
|
|
"compaction_options_universal",
|
|
|
|
&universal_compaction_options_type_info,
|
|
|
|
offsetof(struct MutableCFOptions, compaction_options_universal),
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable)},
|
|
|
|
{"ttl",
|
|
|
|
{offsetof(struct MutableCFOptions, ttl), OptionType::kUInt64T,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kMutable}},
|
|
|
|
{"periodic_compaction_seconds",
|
|
|
|
{offsetof(struct MutableCFOptions, periodic_compaction_seconds),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"enable_blob_files",
|
|
|
|
{offsetof(struct MutableCFOptions, enable_blob_files),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"min_blob_size",
|
|
|
|
{offsetof(struct MutableCFOptions, min_blob_size),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"blob_file_size",
|
|
|
|
{offsetof(struct MutableCFOptions, blob_file_size),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"blob_compression_type",
|
|
|
|
{offsetof(struct MutableCFOptions, blob_compression_type),
|
2020-04-03 19:48:46 +02:00
|
|
|
OptionType::kCompressionType, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"sample_for_compression",
|
|
|
|
{offsetof(struct MutableCFOptions, sample_for_compression),
|
|
|
|
OptionType::kUInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{"bottommost_compression",
|
|
|
|
{offsetof(struct MutableCFOptions, bottommost_compression),
|
|
|
|
OptionType::kCompressionType, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kMutable}},
|
|
|
|
{kOptNameCompOpts,
|
|
|
|
OptionTypeInfo::Struct(
|
|
|
|
kOptNameCompOpts, &compression_options_type_info,
|
|
|
|
offsetof(struct MutableCFOptions, compression_opts),
|
|
|
|
OptionVerificationType::kNormal,
|
|
|
|
(OptionTypeFlags::kMutable | OptionTypeFlags::kCompareNever),
|
|
|
|
[](const ConfigOptions& opts, const std::string& name,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
// This is to handle backward compatibility, where
|
|
|
|
// compression_options was a ":" separated list.
|
|
|
|
if (name == kOptNameCompOpts &&
|
|
|
|
value.find("=") == std::string::npos) {
|
|
|
|
auto* compression =
|
|
|
|
reinterpret_cast<CompressionOptions*>(addr);
|
|
|
|
return ParseCompressionOptions(value, name, *compression);
|
|
|
|
} else {
|
|
|
|
return OptionTypeInfo::ParseStruct(
|
|
|
|
opts, kOptNameCompOpts, &compression_options_type_info,
|
|
|
|
name, value, addr);
|
|
|
|
}
|
|
|
|
})},
|
|
|
|
{kOptNameBMCompOpts,
|
|
|
|
OptionTypeInfo::Struct(
|
|
|
|
kOptNameBMCompOpts, &compression_options_type_info,
|
|
|
|
offsetof(struct MutableCFOptions, bottommost_compression_opts),
|
|
|
|
OptionVerificationType::kNormal,
|
|
|
|
(OptionTypeFlags::kMutable | OptionTypeFlags::kCompareNever),
|
|
|
|
[](const ConfigOptions& opts, const std::string& name,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
// This is to handle backward compatibility, where
|
|
|
|
// compression_options was a ":" separated list.
|
|
|
|
if (name == kOptNameBMCompOpts &&
|
|
|
|
value.find("=") == std::string::npos) {
|
|
|
|
auto* compression =
|
|
|
|
reinterpret_cast<CompressionOptions*>(addr);
|
|
|
|
return ParseCompressionOptions(value, name, *compression);
|
|
|
|
} else {
|
|
|
|
return OptionTypeInfo::ParseStruct(
|
|
|
|
opts, kOptNameBMCompOpts, &compression_options_type_info,
|
|
|
|
name, value, addr);
|
|
|
|
}
|
|
|
|
})},
|
|
|
|
// End special case properties
|
|
|
|
};
|
|
|
|
|
|
|
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
|
|
cf_immutable_options_type_info = {
|
|
|
|
/* not yet supported
|
|
|
|
CompressionOptions compression_opts;
|
|
|
|
TablePropertiesCollectorFactories table_properties_collector_factories;
|
|
|
|
typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>
|
|
|
|
TablePropertiesCollectorFactories;
|
|
|
|
UpdateStatus (*inplace_callback)(char* existing_value,
|
|
|
|
uint34_t* existing_value_size,
|
|
|
|
Slice delta_value,
|
|
|
|
std::string* merged_value);
|
|
|
|
std::vector<DbPath> cf_paths;
|
|
|
|
*/
|
|
|
|
{"compaction_measure_io_stats",
|
|
|
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"inplace_update_support",
|
|
|
|
{offset_of(&ColumnFamilyOptions::inplace_update_support),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"level_compaction_dynamic_level_bytes",
|
|
|
|
{offset_of(&ColumnFamilyOptions::level_compaction_dynamic_level_bytes),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"optimize_filters_for_hits",
|
|
|
|
{offset_of(&ColumnFamilyOptions::optimize_filters_for_hits),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"force_consistency_checks",
|
|
|
|
{offset_of(&ColumnFamilyOptions::force_consistency_checks),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"purge_redundant_kvs_while_flush",
|
|
|
|
{offset_of(&ColumnFamilyOptions::purge_redundant_kvs_while_flush),
|
|
|
|
OptionType::kBoolean, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"max_mem_compaction_level",
|
|
|
|
{0, OptionType::kInt, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"max_write_buffer_number_to_maintain",
|
|
|
|
{offset_of(&ColumnFamilyOptions::max_write_buffer_number_to_maintain),
|
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone, 0}},
|
|
|
|
{"max_write_buffer_size_to_maintain",
|
|
|
|
{offset_of(&ColumnFamilyOptions::max_write_buffer_size_to_maintain),
|
|
|
|
OptionType::kInt64T, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone}},
|
|
|
|
{"min_write_buffer_number_to_merge",
|
|
|
|
{offset_of(&ColumnFamilyOptions::min_write_buffer_number_to_merge),
|
|
|
|
OptionType::kInt, OptionVerificationType::kNormal,
|
|
|
|
OptionTypeFlags::kNone, 0}},
|
|
|
|
{"num_levels",
|
|
|
|
{offset_of(&ColumnFamilyOptions::num_levels), OptionType::kInt,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
|
|
|
|
{"bloom_locality",
|
|
|
|
{offset_of(&ColumnFamilyOptions::bloom_locality), OptionType::kUInt32T,
|
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
|
|
|
|
{"rate_limit_delay_max_milliseconds",
|
|
|
|
{0, OptionType::kUInt, OptionVerificationType::kDeprecated,
|
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"compression_per_level",
|
2020-06-03 21:19:54 +02:00
|
|
|
OptionTypeInfo::Vector<CompressionType>(
|
|
|
|
offset_of(&ColumnFamilyOptions::compression_per_level),
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kNormal, OptionTypeFlags::kNone,
|
2020-06-03 21:19:54 +02:00
|
|
|
{0, OptionType::kCompressionType})},
|
2020-04-29 03:02:11 +02:00
|
|
|
{"comparator",
|
2020-04-03 19:48:46 +02:00
|
|
|
{offset_of(&ColumnFamilyOptions::comparator), OptionType::kComparator,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionVerificationType::kByName, OptionTypeFlags::kCompareLoose,
|
2020-04-29 03:02:11 +02:00
|
|
|
// Parses the string and sets the corresponding comparator
|
|
|
|
[](const ConfigOptions& /*opts*/, const std::string& /*name*/,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
auto old_comparator = reinterpret_cast<const Comparator**>(addr);
|
|
|
|
const Comparator* new_comparator = *old_comparator;
|
|
|
|
Status status = ObjectRegistry::NewInstance()->NewStaticObject(
|
|
|
|
value, &new_comparator);
|
|
|
|
if (status.ok()) {
|
|
|
|
*old_comparator = new_comparator;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_insert_with_hint_prefix_extractor",
|
|
|
|
{offset_of(
|
|
|
|
&ColumnFamilyOptions::memtable_insert_with_hint_prefix_extractor),
|
|
|
|
OptionType::kSliceTransform, OptionVerificationType::kByNameAllowNull,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"memtable_factory",
|
|
|
|
{offset_of(&ColumnFamilyOptions::memtable_factory),
|
|
|
|
OptionType::kMemTableRepFactory, OptionVerificationType::kByName,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-29 03:02:11 +02:00
|
|
|
{"memtable",
|
|
|
|
{offset_of(&ColumnFamilyOptions::memtable_factory),
|
|
|
|
OptionType::kMemTableRepFactory, OptionVerificationType::kAlias,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone,
|
2020-04-29 03:02:11 +02:00
|
|
|
// Parses the value string and updates the memtable_factory
|
|
|
|
[](const ConfigOptions& /*opts*/, const std::string& /*name*/,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
std::unique_ptr<MemTableRepFactory> new_mem_factory;
|
|
|
|
Status s = GetMemTableRepFactoryFromString(value, &new_mem_factory);
|
|
|
|
if (s.ok()) {
|
|
|
|
auto memtable_factory =
|
|
|
|
reinterpret_cast<std::shared_ptr<MemTableRepFactory>*>(addr);
|
|
|
|
memtable_factory->reset(new_mem_factory.release());
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"table_factory",
|
|
|
|
{offset_of(&ColumnFamilyOptions::table_factory),
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionType::kConfigurable, OptionVerificationType::kByName,
|
|
|
|
(OptionTypeFlags::kShared | OptionTypeFlags::kCompareLoose |
|
|
|
|
OptionTypeFlags::kDontPrepare),
|
|
|
|
// Creates a new TableFactory based on value
|
|
|
|
[](const ConfigOptions& opts, const std::string& /*name*/,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
auto table_factory =
|
|
|
|
reinterpret_cast<std::shared_ptr<TableFactory>*>(addr);
|
|
|
|
return TableFactory::CreateFromString(opts, value, table_factory);
|
|
|
|
},
|
|
|
|
// Converts the TableFactory into its string representation
|
|
|
|
[](const ConfigOptions& /*opts*/, const std::string& /*name*/,
|
|
|
|
const char* addr, std::string* value) {
|
|
|
|
const auto* table_factory =
|
|
|
|
reinterpret_cast<const std::shared_ptr<TableFactory>*>(addr);
|
|
|
|
*value = table_factory->get() ? table_factory->get()->Name()
|
|
|
|
: kNullptrString;
|
|
|
|
return Status::OK();
|
|
|
|
},
|
|
|
|
/* No equals function for table factories */ nullptr}},
|
2020-04-29 03:02:11 +02:00
|
|
|
{"block_based_table_factory",
|
|
|
|
{offset_of(&ColumnFamilyOptions::table_factory),
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionType::kConfigurable, OptionVerificationType::kAlias,
|
|
|
|
OptionTypeFlags::kShared | OptionTypeFlags::kCompareLoose,
|
2020-04-29 03:02:11 +02:00
|
|
|
// Parses the input value and creates a BlockBasedTableFactory
|
2020-09-15 01:59:00 +02:00
|
|
|
[](const ConfigOptions& opts, const std::string& name,
|
2020-04-29 03:02:11 +02:00
|
|
|
const std::string& value, char* addr) {
|
2020-09-15 01:59:00 +02:00
|
|
|
BlockBasedTableOptions* old_opts = nullptr;
|
|
|
|
auto table_factory =
|
2020-04-29 03:02:11 +02:00
|
|
|
reinterpret_cast<std::shared_ptr<TableFactory>*>(addr);
|
2020-09-15 01:59:00 +02:00
|
|
|
if (table_factory->get() != nullptr) {
|
|
|
|
old_opts =
|
|
|
|
table_factory->get()->GetOptions<BlockBasedTableOptions>();
|
2020-04-29 03:02:11 +02:00
|
|
|
}
|
2020-09-15 01:59:00 +02:00
|
|
|
if (name == "block_based_table_factory") {
|
|
|
|
std::unique_ptr<TableFactory> new_factory;
|
|
|
|
if (old_opts != nullptr) {
|
|
|
|
new_factory.reset(NewBlockBasedTableFactory(*old_opts));
|
|
|
|
} else {
|
|
|
|
new_factory.reset(NewBlockBasedTableFactory());
|
|
|
|
}
|
|
|
|
Status s = new_factory->ConfigureFromString(opts, value);
|
|
|
|
if (s.ok()) {
|
|
|
|
table_factory->reset(new_factory.release());
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
} else if (old_opts != nullptr) {
|
|
|
|
return table_factory->get()->ConfigureOption(opts, name, value);
|
|
|
|
} else {
|
|
|
|
return Status::NotFound("Mismatched table option: ", name);
|
2020-04-29 03:02:11 +02:00
|
|
|
}
|
|
|
|
}}},
|
|
|
|
{"plain_table_factory",
|
|
|
|
{offset_of(&ColumnFamilyOptions::table_factory),
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionType::kConfigurable, OptionVerificationType::kAlias,
|
|
|
|
OptionTypeFlags::kShared | OptionTypeFlags::kCompareLoose,
|
2020-04-29 03:02:11 +02:00
|
|
|
// Parses the input value and creates a PlainTableFactory
|
2020-09-15 01:59:00 +02:00
|
|
|
[](const ConfigOptions& opts, const std::string& name,
|
2020-04-29 03:02:11 +02:00
|
|
|
const std::string& value, char* addr) {
|
2020-09-15 01:59:00 +02:00
|
|
|
PlainTableOptions* old_opts = nullptr;
|
|
|
|
auto table_factory =
|
2020-04-29 03:02:11 +02:00
|
|
|
reinterpret_cast<std::shared_ptr<TableFactory>*>(addr);
|
2020-09-15 01:59:00 +02:00
|
|
|
if (table_factory->get() != nullptr) {
|
|
|
|
old_opts = table_factory->get()->GetOptions<PlainTableOptions>();
|
2020-04-29 03:02:11 +02:00
|
|
|
}
|
2020-09-15 01:59:00 +02:00
|
|
|
if (name == "plain_table_factory") {
|
|
|
|
std::unique_ptr<TableFactory> new_factory;
|
|
|
|
if (old_opts != nullptr) {
|
|
|
|
new_factory.reset(NewPlainTableFactory(*old_opts));
|
|
|
|
} else {
|
|
|
|
new_factory.reset(NewPlainTableFactory());
|
|
|
|
}
|
|
|
|
Status s = new_factory->ConfigureFromString(opts, value);
|
|
|
|
if (s.ok()) {
|
|
|
|
table_factory->reset(new_factory.release());
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
} else if (old_opts != nullptr) {
|
|
|
|
return table_factory->get()->ConfigureOption(opts, name, value);
|
|
|
|
} else {
|
|
|
|
return Status::NotFound("Mismatched table option: ", name);
|
2020-04-29 03:02:11 +02:00
|
|
|
}
|
|
|
|
}}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"compaction_filter",
|
|
|
|
{offset_of(&ColumnFamilyOptions::compaction_filter),
|
|
|
|
OptionType::kCompactionFilter, OptionVerificationType::kByName,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"compaction_filter_factory",
|
|
|
|
{offset_of(&ColumnFamilyOptions::compaction_filter_factory),
|
|
|
|
OptionType::kCompactionFilterFactory, OptionVerificationType::kByName,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-29 03:02:11 +02:00
|
|
|
{"merge_operator",
|
2020-04-03 19:48:46 +02:00
|
|
|
{offset_of(&ColumnFamilyOptions::merge_operator),
|
|
|
|
OptionType::kMergeOperator,
|
2020-04-29 03:02:11 +02:00
|
|
|
OptionVerificationType::kByNameAllowFromNull,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kCompareLoose,
|
2020-04-29 03:02:11 +02:00
|
|
|
// Parses the input value as a MergeOperator, updating the value
|
|
|
|
[](const ConfigOptions& /*opts*/, const std::string& /*name*/,
|
|
|
|
const std::string& value, char* addr) {
|
|
|
|
auto mop = reinterpret_cast<std::shared_ptr<MergeOperator>*>(addr);
|
2020-09-15 01:59:00 +02:00
|
|
|
Status status =
|
|
|
|
ObjectRegistry::NewInstance()->NewSharedObject<MergeOperator>(
|
|
|
|
value, mop);
|
|
|
|
// Only support static comparator for now.
|
|
|
|
if (status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
2020-04-29 03:02:11 +02:00
|
|
|
return Status::OK();
|
|
|
|
}}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"compaction_style",
|
|
|
|
{offset_of(&ColumnFamilyOptions::compaction_style),
|
|
|
|
OptionType::kCompactionStyle, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-03 19:48:46 +02:00
|
|
|
{"compaction_pri",
|
|
|
|
{offset_of(&ColumnFamilyOptions::compaction_pri),
|
|
|
|
OptionType::kCompactionPri, OptionVerificationType::kNormal,
|
2020-09-15 01:59:00 +02:00
|
|
|
OptionTypeFlags::kNone}},
|
2020-04-29 03:02:11 +02:00
|
|
|
};
|
2020-04-03 19:48:46 +02:00
|
|
|
|
2020-09-15 01:59:00 +02:00
|
|
|
const std::string OptionsHelper::kCFOptionsName = "ColumnFamilyOptions";
|
|
|
|
|
|
|
|
class ConfigurableMutableCFOptions : public Configurable {
|
|
|
|
public:
|
|
|
|
ConfigurableMutableCFOptions(const MutableCFOptions& mcf) {
|
|
|
|
mutable_ = mcf;
|
|
|
|
ConfigurableHelper::RegisterOptions(*this, &mutable_,
|
|
|
|
&cf_mutable_options_type_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MutableCFOptions mutable_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigurableCFOptions : public ConfigurableMutableCFOptions {
|
|
|
|
public:
|
|
|
|
ConfigurableCFOptions(const ColumnFamilyOptions& opts,
|
|
|
|
const std::unordered_map<std::string, std::string>* map)
|
|
|
|
: ConfigurableMutableCFOptions(MutableCFOptions(opts)),
|
|
|
|
immutable_(opts),
|
|
|
|
cf_options_(opts),
|
|
|
|
opt_map_(map) {
|
|
|
|
ConfigurableHelper::RegisterOptions(*this, OptionsHelper::kCFOptionsName,
|
|
|
|
&immutable_,
|
|
|
|
&cf_immutable_options_type_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
Status s = ConfigurableHelper::ConfigureOptions(config_options, *this,
|
|
|
|
opts_map, unused);
|
|
|
|
if (s.ok()) {
|
|
|
|
cf_options_ = BuildColumnFamilyOptions(immutable_, mutable_);
|
|
|
|
s = PrepareOptions(config_options);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const void* GetOptionsPtr(const std::string& name) const override {
|
|
|
|
if (name == OptionsHelper::kCFOptionsName) {
|
|
|
|
return &cf_options_;
|
2020-05-21 19:56:40 +02:00
|
|
|
} else {
|
2020-09-15 01:59:00 +02:00
|
|
|
return ConfigurableMutableCFOptions::GetOptionsPtr(name);
|
2020-04-03 19:48:46 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-15 01:59:00 +02: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ColumnFamilyOptions immutable_;
|
|
|
|
ColumnFamilyOptions cf_options_;
|
|
|
|
const std::unordered_map<std::string, std::string>* opt_map_;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<Configurable> CFOptionsAsConfigurable(
|
|
|
|
const MutableCFOptions& opts) {
|
|
|
|
std::unique_ptr<Configurable> ptr(new ConfigurableMutableCFOptions(opts));
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
std::unique_ptr<Configurable> CFOptionsAsConfigurable(
|
|
|
|
const ColumnFamilyOptions& opts,
|
|
|
|
const std::unordered_map<std::string, std::string>* opt_map) {
|
|
|
|
std::unique_ptr<Configurable> ptr(new ConfigurableCFOptions(opts, opt_map));
|
|
|
|
return ptr;
|
2020-04-03 19:48:46 +02:00
|
|
|
}
|
|
|
|
#endif // ROCKSDB_LITE
|
2014-10-02 01:19:16 +02:00
|
|
|
|
2016-09-02 23:16:31 +02:00
|
|
|
ImmutableCFOptions::ImmutableCFOptions(const Options& options)
|
2016-09-24 01:34:04 +02:00
|
|
|
: ImmutableCFOptions(ImmutableDBOptions(options), options) {}
|
|
|
|
|
|
|
|
ImmutableCFOptions::ImmutableCFOptions(const ImmutableDBOptions& db_options,
|
|
|
|
const ColumnFamilyOptions& cf_options)
|
|
|
|
: compaction_style(cf_options.compaction_style),
|
|
|
|
compaction_pri(cf_options.compaction_pri),
|
2016-10-21 20:31:42 +02:00
|
|
|
user_comparator(cf_options.comparator),
|
2016-11-21 21:07:09 +01:00
|
|
|
internal_comparator(InternalKeyComparator(cf_options.comparator)),
|
2016-09-24 01:34:04 +02:00
|
|
|
merge_operator(cf_options.merge_operator.get()),
|
|
|
|
compaction_filter(cf_options.compaction_filter),
|
|
|
|
compaction_filter_factory(cf_options.compaction_filter_factory.get()),
|
|
|
|
min_write_buffer_number_to_merge(
|
|
|
|
cf_options.min_write_buffer_number_to_merge),
|
|
|
|
max_write_buffer_number_to_maintain(
|
|
|
|
cf_options.max_write_buffer_number_to_maintain),
|
Refactor trimming logic for immutable memtables (#5022)
Summary:
MyRocks currently sets `max_write_buffer_number_to_maintain` in order to maintain enough history for transaction conflict checking. The effectiveness of this approach depends on the size of memtables. When memtables are small, it may not keep enough history; when memtables are large, this may consume too much memory.
We are proposing a new way to configure memtable list history: by limiting the memory usage of immutable memtables. The new option is `max_write_buffer_size_to_maintain` and it will take precedence over the old `max_write_buffer_number_to_maintain` if they are both set to non-zero values. The new option accounts for the total memory usage of flushed immutable memtables and mutable memtable. When the total usage exceeds the limit, RocksDB may start dropping immutable memtables (which is also called trimming history), starting from the oldest one.
The semantics of the old option actually works both as an upper bound and lower bound. History trimming will start if number of immutable memtables exceeds the limit, but it will never go below (limit-1) due to history trimming.
In order the mimic the behavior with the new option, history trimming will stop if dropping the next immutable memtable causes the total memory usage go below the size limit. For example, assuming the size limit is set to 64MB, and there are 3 immutable memtables with sizes of 20, 30, 30. Although the total memory usage is 80MB > 64MB, dropping the oldest memtable will reduce the memory usage to 60MB < 64MB, so in this case no memtable will be dropped.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5022
Differential Revision: D14394062
Pulled By: miasantreble
fbshipit-source-id: 60457a509c6af89d0993f988c9b5c2aa9e45f5c5
2019-08-23 22:54:09 +02:00
|
|
|
max_write_buffer_size_to_maintain(
|
|
|
|
cf_options.max_write_buffer_size_to_maintain),
|
2016-09-24 01:34:04 +02:00
|
|
|
inplace_update_support(cf_options.inplace_update_support),
|
|
|
|
inplace_callback(cf_options.inplace_callback),
|
|
|
|
info_log(db_options.info_log.get()),
|
|
|
|
statistics(db_options.statistics.get()),
|
2017-06-13 23:51:22 +02:00
|
|
|
rate_limiter(db_options.rate_limiter.get()),
|
2018-02-01 23:20:25 +01:00
|
|
|
info_log_level(db_options.info_log_level),
|
2016-09-24 01:34:04 +02:00
|
|
|
env(db_options.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 23:47:08 +01:00
|
|
|
fs(db_options.fs.get()),
|
2016-09-24 01:34:04 +02:00
|
|
|
allow_mmap_reads(db_options.allow_mmap_reads),
|
|
|
|
allow_mmap_writes(db_options.allow_mmap_writes),
|
|
|
|
db_paths(db_options.db_paths),
|
|
|
|
memtable_factory(cf_options.memtable_factory.get()),
|
|
|
|
table_factory(cf_options.table_factory.get()),
|
2016-09-02 23:16:31 +02:00
|
|
|
table_properties_collector_factories(
|
2016-09-24 01:34:04 +02:00
|
|
|
cf_options.table_properties_collector_factories),
|
|
|
|
advise_random_on_open(db_options.advise_random_on_open),
|
|
|
|
bloom_locality(cf_options.bloom_locality),
|
|
|
|
purge_redundant_kvs_while_flush(
|
|
|
|
cf_options.purge_redundant_kvs_while_flush),
|
|
|
|
use_fsync(db_options.use_fsync),
|
|
|
|
compression_per_level(cf_options.compression_per_level),
|
2016-09-02 23:16:31 +02:00
|
|
|
level_compaction_dynamic_level_bytes(
|
2016-09-24 01:34:04 +02:00
|
|
|
cf_options.level_compaction_dynamic_level_bytes),
|
|
|
|
access_hint_on_compaction_start(
|
|
|
|
db_options.access_hint_on_compaction_start),
|
2016-09-02 23:16:31 +02:00
|
|
|
new_table_reader_for_compaction_inputs(
|
2016-09-24 01:34:04 +02:00
|
|
|
db_options.new_table_reader_for_compaction_inputs),
|
|
|
|
num_levels(cf_options.num_levels),
|
|
|
|
optimize_filters_for_hits(cf_options.optimize_filters_for_hits),
|
2016-10-08 02:21:45 +02:00
|
|
|
force_consistency_checks(cf_options.force_consistency_checks),
|
2017-05-17 20:32:26 +02:00
|
|
|
allow_ingest_behind(db_options.allow_ingest_behind),
|
Added support for differential snapshots
Summary:
The motivation for this PR is to add to RocksDB support for differential (incremental) snapshots, as snapshot of the DB changes between two points in time (one can think of it as diff between to sequence numbers, or the diff D which can be thought of as an SST file or just set of KVs that can be applied to sequence number S1 to get the database to the state at sequence number S2).
This feature would be useful for various distributed storages layers built on top of RocksDB, as it should help reduce resources (time and network bandwidth) needed to recover and rebuilt DB instances as replicas in the context of distributed storages.
From the API standpoint that would like client app requesting iterator between (start seqnum) and current DB state, and reading the "diff".
This is a very draft PR for initial review in the discussion on the approach, i'm going to rework some parts and keep updating the PR.
For now, what's done here according to initial discussions:
Preserving deletes:
- We want to be able to optionally preserve recent deletes for some defined period of time, so that if a delete came in recently and might need to be included in the next incremental snapshot it would't get dropped by a compaction. This is done by adding new param to Options (preserve deletes flag) and new variable to DB Impl where we keep track of the sequence number after which we don't want to drop tombstones, even if they are otherwise eligible for deletion.
- I also added a new API call for clients to be able to advance this cutoff seqnum after which we drop deletes; i assume it's more flexible to let clients control this, since otherwise we'd need to keep some kind of timestamp < -- > seqnum mapping inside the DB, which sounds messy and painful to support. Clients could make use of it by periodically calling GetLatestSequenceNumber(), noting the timestamp, doing some calculation and figuring out by how much we need to advance the cutoff seqnum.
- Compaction codepath in compaction_iterator.cc has been modified to avoid dropping tombstones with seqnum > cutoff seqnum.
Iterator changes:
- couple params added to ReadOptions, to optionally allow client to request internal keys instead of user keys (so that client can get the latest value of a key, be it delete marker or a put), as well as min timestamp and min seqnum.
TableCache changes:
- I modified table_cache code to be able to quickly exclude SST files from iterators heep if creation_time on the file is less then iter_start_ts as passed in ReadOptions. That would help a lot in some DB settings (like reading very recent data only or using FIFO compactions), but not so much for universal compaction with more or less long iterator time span.
What's left:
- Still looking at how to best plug that inside DBIter codepath. So far it seems that FindNextUserKeyInternal only parses values as UserKeys, and iter->key() call generally returns user key. Can we add new API to DBIter as internal_key(), and modify this internal method to optionally set saved_key_ to point to the full internal key? I don't need to store actual seqnum there, but I do need to store type.
Closes https://github.com/facebook/rocksdb/pull/2999
Differential Revision: D6175602
Pulled By: mikhail-antonov
fbshipit-source-id: c779a6696ee2d574d86c69cec866a3ae095aa900
2017-11-02 02:43:29 +01:00
|
|
|
preserve_deletes(db_options.preserve_deletes),
|
2016-09-24 01:34:04 +02:00
|
|
|
listeners(db_options.listeners),
|
|
|
|
row_cache(db_options.row_cache),
|
2016-11-14 03:58:17 +01:00
|
|
|
memtable_insert_with_hint_prefix_extractor(
|
2018-04-03 06:57:28 +02:00
|
|
|
cf_options.memtable_insert_with_hint_prefix_extractor.get()),
|
Concurrent task limiter for compaction thread control (#4332)
Summary:
The PR is targeting to resolve the issue of:
https://github.com/facebook/rocksdb/issues/3972#issue-330771918
We have a rocksdb created with leveled-compaction with multiple column families (CFs), some of CFs are using HDD to store big and less frequently accessed data and others are using SSD.
When there are continuously write traffics going on to all CFs, the compaction thread pool is mostly occupied by those slow HDD compactions, which blocks fully utilize SSD bandwidth.
Since atomic write and transaction is needed across CFs, so splitting it to multiple rocksdb instance is not an option for us.
With the compaction thread control, we got 30%+ HDD write throughput gain, and also a lot smooth SSD write since less write stall happening.
ConcurrentTaskLimiter can be shared with multi-CFs across rocksdb instances, so the feature does not only work for multi-CFs scenarios, but also for multi-rocksdbs scenarios, who need disk IO resource control per tenant.
The usage is straight forward:
e.g.:
//
// Enable compaction thread limiter thru ColumnFamilyOptions
//
std::shared_ptr<ConcurrentTaskLimiter> ctl(NewConcurrentTaskLimiter("foo_limiter", 4));
Options options;
ColumnFamilyOptions cf_opt(options);
cf_opt.compaction_thread_limiter = ctl;
...
//
// Compaction thread limiter can be tuned or disabled on-the-fly
//
ctl->SetMaxOutstandingTask(12); // enlarge to 12 tasks
...
ctl->ResetMaxOutstandingTask(); // disable (bypass) thread limiter
ctl->SetMaxOutstandingTask(-1); // Same as above
...
ctl->SetMaxOutstandingTask(0); // full throttle (0 task)
//
// Sharing compaction thread limiter among CFs (to resolve multiple storage perf issue)
//
std::shared_ptr<ConcurrentTaskLimiter> ctl_ssd(NewConcurrentTaskLimiter("ssd_limiter", 8));
std::shared_ptr<ConcurrentTaskLimiter> ctl_hdd(NewConcurrentTaskLimiter("hdd_limiter", 4));
Options options;
ColumnFamilyOptions cf_opt_ssd1(options);
ColumnFamilyOptions cf_opt_ssd2(options);
ColumnFamilyOptions cf_opt_hdd1(options);
ColumnFamilyOptions cf_opt_hdd2(options);
ColumnFamilyOptions cf_opt_hdd3(options);
// SSD CFs
cf_opt_ssd1.compaction_thread_limiter = ctl_ssd;
cf_opt_ssd2.compaction_thread_limiter = ctl_ssd;
// HDD CFs
cf_opt_hdd1.compaction_thread_limiter = ctl_hdd;
cf_opt_hdd2.compaction_thread_limiter = ctl_hdd;
cf_opt_hdd3.compaction_thread_limiter = ctl_hdd;
...
//
// The limiter is disabled by default (or set to nullptr explicitly)
//
Options options;
ColumnFamilyOptions cf_opt(options);
cf_opt.compaction_thread_limiter = nullptr;
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4332
Differential Revision: D13226590
Pulled By: siying
fbshipit-source-id: 14307aec55b8bd59c8223d04aa6db3c03d1b0c1d
2018-12-13 22:16:04 +01:00
|
|
|
cf_paths(cf_options.cf_paths),
|
2020-02-11 00:42:46 +01:00
|
|
|
compaction_thread_limiter(cf_options.compaction_thread_limiter),
|
2020-07-24 22:43:14 +02:00
|
|
|
file_checksum_gen_factory(db_options.file_checksum_gen_factory.get()),
|
2020-09-30 08:16:12 +02:00
|
|
|
sst_partitioner_factory(cf_options.sst_partitioner_factory),
|
2020-10-19 20:37:05 +02:00
|
|
|
allow_data_in_errors(db_options.allow_data_in_errors),
|
|
|
|
db_host_id(db_options.db_host_id) {}
|
2016-09-02 23:16:31 +02:00
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
// Multiple two operands. If they overflow, return op1.
|
2016-11-02 05:05:32 +01:00
|
|
|
uint64_t MultiplyCheckOverflow(uint64_t op1, double op2) {
|
|
|
|
if (op1 == 0 || op2 <= 0) {
|
2014-10-02 01:19:16 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2016-11-02 05:05:32 +01:00
|
|
|
if (port::kMaxUint64 / op1 < op2) {
|
2014-10-02 01:19:16 +02:00
|
|
|
return op1;
|
|
|
|
}
|
2016-11-02 05:05:32 +01:00
|
|
|
return static_cast<uint64_t>(op1 * op2);
|
2014-10-02 01:19:16 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 01:35:46 +02:00
|
|
|
// when level_compaction_dynamic_level_bytes is true and leveled compaction
|
|
|
|
// is used, the base level is not always L1, so precomupted max_file_size can
|
|
|
|
// no longer be used. Recompute file_size_for_level from base level.
|
|
|
|
uint64_t MaxFileSizeForLevel(const MutableCFOptions& cf_options,
|
|
|
|
int level, CompactionStyle compaction_style, int base_level,
|
|
|
|
bool level_compaction_dynamic_level_bytes) {
|
|
|
|
if (!level_compaction_dynamic_level_bytes || level < base_level ||
|
|
|
|
compaction_style != kCompactionStyleLevel) {
|
|
|
|
assert(level >= 0);
|
|
|
|
assert(level < (int)cf_options.max_file_size.size());
|
|
|
|
return cf_options.max_file_size[level];
|
|
|
|
} else {
|
|
|
|
assert(level >= 0 && base_level >= 0);
|
|
|
|
assert(level - base_level < (int)cf_options.max_file_size.size());
|
|
|
|
return cf_options.max_file_size[level - base_level];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-10 01:49:07 +02:00
|
|
|
size_t MaxFileSizeForL0MetaPin(const MutableCFOptions& cf_options) {
|
|
|
|
// We do not want to pin meta-blocks that almost certainly came from intra-L0
|
|
|
|
// or a former larger `write_buffer_size` value to avoid surprising users with
|
|
|
|
// pinned memory usage. We use a factor of 1.5 to account for overhead
|
|
|
|
// introduced during flush in most cases.
|
|
|
|
if (port::kMaxSizet / 3 < cf_options.write_buffer_size / 2) {
|
|
|
|
return port::kMaxSizet;
|
|
|
|
}
|
|
|
|
return cf_options.write_buffer_size / 2 * 3;
|
|
|
|
}
|
|
|
|
|
2016-09-14 06:11:59 +02:00
|
|
|
void MutableCFOptions::RefreshDerivedOptions(int num_levels,
|
|
|
|
CompactionStyle compaction_style) {
|
|
|
|
max_file_size.resize(num_levels);
|
|
|
|
for (int i = 0; i < num_levels; ++i) {
|
|
|
|
if (i == 0 && compaction_style == kCompactionStyleUniversal) {
|
2014-10-02 01:19:16 +02:00
|
|
|
max_file_size[i] = ULLONG_MAX;
|
|
|
|
} else if (i > 1) {
|
|
|
|
max_file_size[i] = MultiplyCheckOverflow(max_file_size[i - 1],
|
|
|
|
target_file_size_multiplier);
|
|
|
|
} else {
|
|
|
|
max_file_size[i] = target_file_size_base;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-17 02:22:28 +02:00
|
|
|
void MutableCFOptions::Dump(Logger* log) const {
|
|
|
|
// Memtable related options
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(log,
|
|
|
|
" write_buffer_size: %" ROCKSDB_PRIszt,
|
|
|
|
write_buffer_size);
|
|
|
|
ROCKS_LOG_INFO(log, " max_write_buffer_number: %d",
|
|
|
|
max_write_buffer_number);
|
|
|
|
ROCKS_LOG_INFO(log,
|
|
|
|
" arena_block_size: %" ROCKSDB_PRIszt,
|
|
|
|
arena_block_size);
|
|
|
|
ROCKS_LOG_INFO(log, " memtable_prefix_bloom_ratio: %f",
|
|
|
|
memtable_prefix_bloom_size_ratio);
|
2019-02-19 21:12:25 +01:00
|
|
|
ROCKS_LOG_INFO(log, " memtable_whole_key_filtering: %d",
|
|
|
|
memtable_whole_key_filtering);
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(log,
|
|
|
|
" memtable_huge_page_size: %" ROCKSDB_PRIszt,
|
|
|
|
memtable_huge_page_size);
|
|
|
|
ROCKS_LOG_INFO(log,
|
|
|
|
" max_successive_merges: %" ROCKSDB_PRIszt,
|
|
|
|
max_successive_merges);
|
|
|
|
ROCKS_LOG_INFO(log,
|
|
|
|
" inplace_update_num_locks: %" ROCKSDB_PRIszt,
|
|
|
|
inplace_update_num_locks);
|
2018-05-21 23:33:55 +02:00
|
|
|
ROCKS_LOG_INFO(
|
|
|
|
log, " prefix_extractor: %s",
|
|
|
|
prefix_extractor == nullptr ? "nullptr" : prefix_extractor->Name());
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(log, " disable_auto_compactions: %d",
|
|
|
|
disable_auto_compactions);
|
|
|
|
ROCKS_LOG_INFO(log, " soft_pending_compaction_bytes_limit: %" PRIu64,
|
|
|
|
soft_pending_compaction_bytes_limit);
|
|
|
|
ROCKS_LOG_INFO(log, " hard_pending_compaction_bytes_limit: %" PRIu64,
|
|
|
|
hard_pending_compaction_bytes_limit);
|
|
|
|
ROCKS_LOG_INFO(log, " level0_file_num_compaction_trigger: %d",
|
|
|
|
level0_file_num_compaction_trigger);
|
|
|
|
ROCKS_LOG_INFO(log, " level0_slowdown_writes_trigger: %d",
|
|
|
|
level0_slowdown_writes_trigger);
|
|
|
|
ROCKS_LOG_INFO(log, " level0_stop_writes_trigger: %d",
|
|
|
|
level0_stop_writes_trigger);
|
|
|
|
ROCKS_LOG_INFO(log, " max_compaction_bytes: %" PRIu64,
|
|
|
|
max_compaction_bytes);
|
|
|
|
ROCKS_LOG_INFO(log, " target_file_size_base: %" PRIu64,
|
|
|
|
target_file_size_base);
|
|
|
|
ROCKS_LOG_INFO(log, " target_file_size_multiplier: %d",
|
|
|
|
target_file_size_multiplier);
|
|
|
|
ROCKS_LOG_INFO(log, " max_bytes_for_level_base: %" PRIu64,
|
|
|
|
max_bytes_for_level_base);
|
|
|
|
ROCKS_LOG_INFO(log, " max_bytes_for_level_multiplier: %f",
|
|
|
|
max_bytes_for_level_multiplier);
|
2018-07-16 23:24:33 +02:00
|
|
|
ROCKS_LOG_INFO(log, " ttl: %" PRIu64,
|
|
|
|
ttl);
|
Periodic Compactions (#5166)
Summary:
Introducing Periodic Compactions.
This feature allows all the files in a CF to be periodically compacted. It could help in catching any corruptions that could creep into the DB proactively as every file is constantly getting re-compacted. And also, of course, it helps to cleanup data older than certain threshold.
- Introduced a new option `periodic_compaction_time` to control how long a file can live without being compacted in a CF.
- This works across all levels.
- The files are put in the same level after going through the compaction. (Related files in the same level are picked up as `ExpandInputstoCleanCut` is used).
- Compaction filters, if any, are invoked as usual.
- A new table property, `file_creation_time`, is introduced to implement this feature. This property is set to the time at which the SST file was created (and that time is given by the underlying Env/OS).
This feature can be enabled on its own, or in conjunction with `ttl`. It is possible to set a different time threshold for the bottom level when used in conjunction with ttl. Since `ttl` works only on 0 to last but one levels, you could set `ttl` to, say, 1 day, and `periodic_compaction_time` to, say, 7 days. Since `ttl < periodic_compaction_time` all files in last but one levels keep getting picked up based on ttl, and almost never based on periodic_compaction_time. The files in the bottom level get picked up for compaction based on `periodic_compaction_time`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5166
Differential Revision: D14884441
Pulled By: sagar0
fbshipit-source-id: 408426cbacb409c06386a98632dcf90bfa1bda47
2019-04-11 04:24:25 +02:00
|
|
|
ROCKS_LOG_INFO(log, " periodic_compaction_seconds: %" PRIu64,
|
|
|
|
periodic_compaction_seconds);
|
2014-10-17 02:22:28 +02:00
|
|
|
std::string result;
|
|
|
|
char buf[10];
|
|
|
|
for (const auto m : max_bytes_for_level_multiplier_additional) {
|
|
|
|
snprintf(buf, sizeof(buf), "%d, ", m);
|
|
|
|
result += buf;
|
|
|
|
}
|
2016-10-08 02:16:13 +02:00
|
|
|
if (result.size() >= 2) {
|
|
|
|
result.resize(result.size() - 2);
|
|
|
|
} else {
|
|
|
|
result = "";
|
|
|
|
}
|
|
|
|
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(log, "max_bytes_for_level_multiplier_additional: %s",
|
|
|
|
result.c_str());
|
|
|
|
ROCKS_LOG_INFO(log, " max_sequential_skip_in_iterations: %" PRIu64,
|
|
|
|
max_sequential_skip_in_iterations);
|
2020-10-01 19:08:52 +02:00
|
|
|
ROCKS_LOG_INFO(log, " check_flush_compaction_key_order: %d",
|
|
|
|
check_flush_compaction_key_order);
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(log, " paranoid_file_checks: %d",
|
|
|
|
paranoid_file_checks);
|
|
|
|
ROCKS_LOG_INFO(log, " report_bg_io_stats: %d",
|
|
|
|
report_bg_io_stats);
|
|
|
|
ROCKS_LOG_INFO(log, " compression: %d",
|
|
|
|
static_cast<int>(compression));
|
2018-07-17 07:12:28 +02:00
|
|
|
|
|
|
|
// Universal Compaction Options
|
|
|
|
ROCKS_LOG_INFO(log, "compaction_options_universal.size_ratio : %d",
|
|
|
|
compaction_options_universal.size_ratio);
|
|
|
|
ROCKS_LOG_INFO(log, "compaction_options_universal.min_merge_width : %d",
|
|
|
|
compaction_options_universal.min_merge_width);
|
|
|
|
ROCKS_LOG_INFO(log, "compaction_options_universal.max_merge_width : %d",
|
|
|
|
compaction_options_universal.max_merge_width);
|
|
|
|
ROCKS_LOG_INFO(
|
|
|
|
log, "compaction_options_universal.max_size_amplification_percent : %d",
|
|
|
|
compaction_options_universal.max_size_amplification_percent);
|
|
|
|
ROCKS_LOG_INFO(log,
|
|
|
|
"compaction_options_universal.compression_size_percent : %d",
|
|
|
|
compaction_options_universal.compression_size_percent);
|
|
|
|
ROCKS_LOG_INFO(log, "compaction_options_universal.stop_style : %d",
|
|
|
|
compaction_options_universal.stop_style);
|
|
|
|
ROCKS_LOG_INFO(
|
|
|
|
log, "compaction_options_universal.allow_trivial_move : %d",
|
|
|
|
static_cast<int>(compaction_options_universal.allow_trivial_move));
|
|
|
|
|
|
|
|
// FIFO Compaction Options
|
|
|
|
ROCKS_LOG_INFO(log, "compaction_options_fifo.max_table_files_size : %" PRIu64,
|
|
|
|
compaction_options_fifo.max_table_files_size);
|
|
|
|
ROCKS_LOG_INFO(log, "compaction_options_fifo.allow_compaction : %d",
|
|
|
|
compaction_options_fifo.allow_compaction);
|
2020-08-19 03:31:31 +02:00
|
|
|
|
|
|
|
// Blob file related options
|
|
|
|
ROCKS_LOG_INFO(log, " enable_blob_files: %s",
|
|
|
|
enable_blob_files ? "true" : "false");
|
|
|
|
ROCKS_LOG_INFO(log, " min_blob_size: %" PRIu64,
|
|
|
|
min_blob_size);
|
|
|
|
ROCKS_LOG_INFO(log, " blob_file_size: %" PRIu64,
|
|
|
|
blob_file_size);
|
|
|
|
ROCKS_LOG_INFO(log, " blob_compression_type: %s",
|
|
|
|
CompressionTypeToString(blob_compression_type).c_str());
|
2014-10-17 02:22:28 +02:00
|
|
|
}
|
|
|
|
|
2018-05-21 23:33:55 +02:00
|
|
|
MutableCFOptions::MutableCFOptions(const Options& options)
|
|
|
|
: MutableCFOptions(ColumnFamilyOptions(options)) {}
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|