2019-12-09 08:49:32 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
|
|
// 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).
|
|
|
|
//
|
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
|
|
|
#ifdef GFLAGS
|
|
|
|
#include "db_stress_tool/db_stress_common.h"
|
|
|
|
|
|
|
|
static bool ValidateUint32Range(const char* flagname, uint64_t value) {
|
|
|
|
if (value > std::numeric_limits<uint32_t>::max()) {
|
|
|
|
fprintf(stderr, "Invalid value for --%s: %lu, overflow\n", flagname,
|
|
|
|
(unsigned long)value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-10-12 01:22:10 +02:00
|
|
|
DEFINE_uint64(seed, 2341234,
|
|
|
|
"Seed for PRNG. When --nooverwritepercent is "
|
|
|
|
"nonzero and --expected_values_dir is nonempty, this value "
|
|
|
|
"must be fixed across invocations.");
|
2019-12-09 08:49:32 +01:00
|
|
|
static const bool FLAGS_seed_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_seed, &ValidateUint32Range);
|
|
|
|
|
|
|
|
DEFINE_bool(read_only, false, "True if open DB in read-only mode during tests");
|
|
|
|
|
|
|
|
DEFINE_int64(max_key, 1 * KB * KB,
|
|
|
|
"Max number of key/values to place in database");
|
|
|
|
|
2020-01-10 06:25:40 +01:00
|
|
|
DEFINE_int32(max_key_len, 3, "Maximum length of a key in 8-byte units");
|
|
|
|
|
|
|
|
DEFINE_string(key_len_percent_dist, "",
|
|
|
|
"Percentages of keys of various lengths. For example, 1,30,69 "
|
|
|
|
"means 1% of keys are 8 bytes, 30% are 16 bytes, and 69% are "
|
|
|
|
"24 bytes. If not specified, it will be evenly distributed");
|
|
|
|
|
|
|
|
DEFINE_int32(key_window_scale_factor, 10,
|
|
|
|
"This value will be multiplied by 100 to come up with a window "
|
|
|
|
"size for varying the key length");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(column_families, 10, "Number of column families");
|
|
|
|
|
2019-12-16 22:59:21 +01:00
|
|
|
DEFINE_double(
|
|
|
|
hot_key_alpha, 0,
|
|
|
|
"Use Zipfian distribution to generate the key "
|
|
|
|
"distribution. If it is not specified, write path will use random "
|
|
|
|
"distribution to generate the keys. The parameter is [0, double_max]). "
|
|
|
|
"However, the larger alpha is, the more shewed will be. If alpha is "
|
|
|
|
"larger than 2, it is likely that only 1 key will be accessed. The "
|
|
|
|
"Recommended value is [0.8-1.5]. The distribution is also related to "
|
|
|
|
"max_key and total iterations of generating the hot key. ");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_string(
|
|
|
|
options_file, "",
|
|
|
|
"The path to a RocksDB options file. If specified, then db_stress will "
|
|
|
|
"run with the RocksDB options in the default column family of the "
|
|
|
|
"specified options file. Note that, when an options file is provided, "
|
|
|
|
"db_stress will ignore the flag values for all options that may be passed "
|
|
|
|
"via options file.");
|
|
|
|
|
|
|
|
DEFINE_int64(
|
|
|
|
active_width, 0,
|
|
|
|
"Number of keys in active span of the key-range at any given time. The "
|
|
|
|
"span begins with its left endpoint at key 0, gradually moves rightwards, "
|
|
|
|
"and ends with its right endpoint at max_key. If set to 0, active_width "
|
|
|
|
"will be sanitized to be equal to max_key.");
|
|
|
|
|
|
|
|
// TODO(noetzli) Add support for single deletes
|
|
|
|
DEFINE_bool(test_batches_snapshots, false,
|
|
|
|
"If set, the test uses MultiGet(), MultiPut() and MultiDelete()"
|
|
|
|
" which read/write/delete multiple keys in a batch. In this mode,"
|
|
|
|
" we do not verify db content by comparing the content with the "
|
|
|
|
"pre-allocated array. Instead, we do partial verification inside"
|
|
|
|
" MultiGet() by checking various values in a batch. Benefit of"
|
|
|
|
" this mode:\n"
|
|
|
|
"\t(a) No need to acquire mutexes during writes (less cache "
|
|
|
|
"flushes in multi-core leading to speed up)\n"
|
|
|
|
"\t(b) No long validation at the end (more speed up)\n"
|
|
|
|
"\t(c) Test snapshot and atomicity of batch writes");
|
|
|
|
|
|
|
|
DEFINE_bool(atomic_flush, false,
|
|
|
|
"If set, enables atomic flush in the options.\n");
|
|
|
|
|
|
|
|
DEFINE_bool(test_cf_consistency, false,
|
|
|
|
"If set, runs the stress test dedicated to verifying writes to "
|
|
|
|
"multiple column families are consistent. Setting this implies "
|
|
|
|
"`atomic_flush=true` is set true if `disable_wal=false`.\n");
|
|
|
|
|
|
|
|
DEFINE_int32(threads, 32, "Number of concurrent threads to run.");
|
|
|
|
|
|
|
|
DEFINE_int32(ttl, -1,
|
|
|
|
"Opens the db with this ttl value if this is not -1. "
|
|
|
|
"Carefully specify a large value such that verifications on "
|
|
|
|
"deleted values don't fail");
|
|
|
|
|
|
|
|
DEFINE_int32(value_size_mult, 8,
|
|
|
|
"Size of value will be this number times rand_int(1,3) bytes");
|
|
|
|
|
|
|
|
DEFINE_int32(compaction_readahead_size, 0, "Compaction readahead size");
|
|
|
|
|
|
|
|
DEFINE_bool(enable_pipelined_write, false, "Pipeline WAL/memtable writes");
|
|
|
|
|
|
|
|
DEFINE_bool(verify_before_write, false, "Verify before write");
|
|
|
|
|
|
|
|
DEFINE_bool(histogram, false, "Print histogram of operation timings");
|
|
|
|
|
|
|
|
DEFINE_bool(destroy_db_initially, true,
|
|
|
|
"Destroys the database dir before start if this is true");
|
|
|
|
|
|
|
|
DEFINE_bool(verbose, false, "Verbose");
|
|
|
|
|
|
|
|
DEFINE_bool(progress_reports, true,
|
|
|
|
"If true, db_stress will report number of finished operations");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_uint64(db_write_buffer_size,
|
|
|
|
ROCKSDB_NAMESPACE::Options().db_write_buffer_size,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Number of bytes to buffer in all memtables before compacting");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int32(
|
|
|
|
write_buffer_size,
|
|
|
|
static_cast<int32_t>(ROCKSDB_NAMESPACE::Options().write_buffer_size),
|
|
|
|
"Number of bytes to buffer in memtable before compacting");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_int32(max_write_buffer_number,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().max_write_buffer_number,
|
2019-12-09 08:49:32 +01:00
|
|
|
"The number of in-memory memtables. "
|
|
|
|
"Each memtable is of size FLAGS_write_buffer_size.");
|
|
|
|
|
|
|
|
DEFINE_int32(min_write_buffer_number_to_merge,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().min_write_buffer_number_to_merge,
|
2019-12-09 08:49:32 +01:00
|
|
|
"The minimum number of write buffers that will be merged together "
|
|
|
|
"before writing to storage. This is cheap because it is an "
|
|
|
|
"in-memory merge. If this feature is not enabled, then all these "
|
|
|
|
"write buffers are flushed to L0 as separate files and this "
|
|
|
|
"increases read amplification because a get request has to check "
|
|
|
|
"in all of these files. Also, an in-memory merge may result in "
|
|
|
|
"writing less data to storage if there are duplicate records in"
|
|
|
|
" each of these individual write buffers.");
|
|
|
|
|
|
|
|
DEFINE_int32(max_write_buffer_number_to_maintain,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().max_write_buffer_number_to_maintain,
|
2019-12-09 08:49:32 +01:00
|
|
|
"The total maximum number of write buffers to maintain in memory "
|
|
|
|
"including copies of buffers that have already been flushed. "
|
|
|
|
"Unlike max_write_buffer_number, this parameter does not affect "
|
|
|
|
"flushing. This controls the minimum amount of write history "
|
|
|
|
"that will be available in memory for conflict checking when "
|
|
|
|
"Transactions are used. If this value is too low, some "
|
|
|
|
"transactions may fail at commit time due to not being able to "
|
|
|
|
"determine whether there were any write conflicts. Setting this "
|
|
|
|
"value to 0 will cause write buffers to be freed immediately "
|
|
|
|
"after they are flushed. If this value is set to -1, "
|
|
|
|
"'max_write_buffer_number' will be used.");
|
|
|
|
|
|
|
|
DEFINE_int64(max_write_buffer_size_to_maintain,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().max_write_buffer_size_to_maintain,
|
2019-12-09 08:49:32 +01:00
|
|
|
"The total maximum size of write buffers to maintain in memory "
|
|
|
|
"including copies of buffers that have already been flushed. "
|
|
|
|
"Unlike max_write_buffer_number, this parameter does not affect "
|
|
|
|
"flushing. This controls the minimum amount of write history "
|
|
|
|
"that will be available in memory for conflict checking when "
|
|
|
|
"Transactions are used. If this value is too low, some "
|
|
|
|
"transactions may fail at commit time due to not being able to "
|
|
|
|
"determine whether there were any write conflicts. Setting this "
|
|
|
|
"value to 0 will cause write buffers to be freed immediately "
|
|
|
|
"after they are flushed. If this value is set to -1, "
|
|
|
|
"'max_write_buffer_number' will be used.");
|
|
|
|
|
|
|
|
DEFINE_double(memtable_prefix_bloom_size_ratio,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().memtable_prefix_bloom_size_ratio,
|
2019-12-09 08:49:32 +01:00
|
|
|
"creates prefix blooms for memtables, each with size "
|
|
|
|
"`write_buffer_size * memtable_prefix_bloom_size_ratio`.");
|
|
|
|
|
|
|
|
DEFINE_bool(memtable_whole_key_filtering,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().memtable_whole_key_filtering,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Enable whole key filtering in memtables.");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int32(open_files, ROCKSDB_NAMESPACE::Options().max_open_files,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Maximum number of files to keep open at the same time "
|
|
|
|
"(use default if == 0)");
|
|
|
|
|
|
|
|
DEFINE_int64(compressed_cache_size, -1,
|
|
|
|
"Number of bytes to use as a cache of compressed data."
|
|
|
|
" Negative means use default settings.");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int32(compaction_style, ROCKSDB_NAMESPACE::Options().compaction_style,
|
|
|
|
"");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
2020-05-07 03:06:04 +02:00
|
|
|
DEFINE_int32(num_levels, ROCKSDB_NAMESPACE::Options().num_levels,
|
|
|
|
"Number of levels in the DB");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(level0_file_num_compaction_trigger,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().level0_file_num_compaction_trigger,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Level0 compaction start trigger");
|
|
|
|
|
|
|
|
DEFINE_int32(level0_slowdown_writes_trigger,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().level0_slowdown_writes_trigger,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Number of files in level-0 that will slow down writes");
|
|
|
|
|
|
|
|
DEFINE_int32(level0_stop_writes_trigger,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().level0_stop_writes_trigger,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Number of files in level-0 that will trigger put stop.");
|
|
|
|
|
|
|
|
DEFINE_int32(block_size,
|
2020-02-20 21:07:53 +01:00
|
|
|
static_cast<int32_t>(
|
|
|
|
ROCKSDB_NAMESPACE::BlockBasedTableOptions().block_size),
|
2019-12-09 08:49:32 +01:00
|
|
|
"Number of bytes in a block.");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int32(format_version,
|
|
|
|
static_cast<int32_t>(
|
|
|
|
ROCKSDB_NAMESPACE::BlockBasedTableOptions().format_version),
|
|
|
|
"Format version of SST files.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int32(
|
|
|
|
index_block_restart_interval,
|
|
|
|
ROCKSDB_NAMESPACE::BlockBasedTableOptions().index_block_restart_interval,
|
|
|
|
"Number of keys between restart points "
|
|
|
|
"for delta encoding of keys in index block.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_int32(max_background_compactions,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().max_background_compactions,
|
2019-12-09 08:49:32 +01:00
|
|
|
"The maximum number of concurrent background compactions "
|
|
|
|
"that can occur in parallel.");
|
|
|
|
|
|
|
|
DEFINE_int32(num_bottom_pri_threads, 0,
|
|
|
|
"The number of threads in the bottom-priority thread pool (used "
|
|
|
|
"by universal compaction only).");
|
|
|
|
|
|
|
|
DEFINE_int32(compaction_thread_pool_adjust_interval, 0,
|
|
|
|
"The interval (in milliseconds) to adjust compaction thread pool "
|
|
|
|
"size. Don't change it periodically if the value is 0.");
|
|
|
|
|
|
|
|
DEFINE_int32(compaction_thread_pool_variations, 2,
|
|
|
|
"Range of background thread pool size variations when adjusted "
|
|
|
|
"periodically.");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int32(max_background_flushes,
|
|
|
|
ROCKSDB_NAMESPACE::Options().max_background_flushes,
|
2019-12-09 08:49:32 +01:00
|
|
|
"The maximum number of concurrent background flushes "
|
|
|
|
"that can occur in parallel.");
|
|
|
|
|
|
|
|
DEFINE_int32(universal_size_ratio, 0,
|
|
|
|
"The ratio of file sizes that trigger"
|
|
|
|
" compaction in universal style");
|
|
|
|
|
|
|
|
DEFINE_int32(universal_min_merge_width, 0,
|
|
|
|
"The minimum number of files to "
|
|
|
|
"compact in universal style compaction");
|
|
|
|
|
|
|
|
DEFINE_int32(universal_max_merge_width, 0,
|
|
|
|
"The max number of files to compact"
|
|
|
|
" in universal style compaction");
|
|
|
|
|
|
|
|
DEFINE_int32(universal_max_size_amplification_percent, 0,
|
|
|
|
"The max size amplification for universal style compaction");
|
|
|
|
|
|
|
|
DEFINE_int32(clear_column_family_one_in, 1000000,
|
|
|
|
"With a chance of 1/N, delete a column family and then recreate "
|
|
|
|
"it again. If N == 0, never drop/create column families. "
|
|
|
|
"When test_batches_snapshots is true, this flag has no effect");
|
|
|
|
|
2020-03-19 01:11:06 +01:00
|
|
|
DEFINE_int32(get_live_files_one_in, 1000000,
|
|
|
|
"With a chance of 1/N, call GetLiveFiles to verify if it returns "
|
|
|
|
"correctly. If N == 0, do not call the interface.");
|
|
|
|
|
|
|
|
DEFINE_int32(
|
|
|
|
get_sorted_wal_files_one_in, 1000000,
|
|
|
|
"With a chance of 1/N, call GetSortedWalFiles to verify if it returns "
|
|
|
|
"correctly. (Note that this API may legitimately return an error.) If N == "
|
|
|
|
"0, do not call the interface.");
|
|
|
|
|
|
|
|
DEFINE_int32(
|
|
|
|
get_current_wal_file_one_in, 1000000,
|
|
|
|
"With a chance of 1/N, call GetCurrentWalFile to verify if it returns "
|
|
|
|
"correctly. (Note that this API may legitimately return an error.) If N == "
|
|
|
|
"0, do not call the interface.");
|
2019-12-20 21:05:48 +01:00
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(set_options_one_in, 0,
|
|
|
|
"With a chance of 1/N, change some random options");
|
|
|
|
|
|
|
|
DEFINE_int32(set_in_place_one_in, 0,
|
|
|
|
"With a chance of 1/N, toggle in place support option");
|
|
|
|
|
|
|
|
DEFINE_int64(cache_size, 2LL * KB * KB * KB,
|
|
|
|
"Number of bytes to use as a cache of uncompressed data.");
|
|
|
|
|
2021-06-28 08:53:47 +02:00
|
|
|
DEFINE_int32(cache_numshardbits, 6,
|
|
|
|
"Number of shards for the block cache"
|
|
|
|
" is 2 ** cache_numshardbits. Negative means use default settings."
|
|
|
|
" This is applied only if FLAGS_cache_size is non-negative.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(cache_index_and_filter_blocks, false,
|
|
|
|
"True if indexes/filters should be cached in block cache.");
|
|
|
|
|
2020-10-11 23:52:49 +02:00
|
|
|
DEFINE_int32(
|
|
|
|
top_level_index_pinning,
|
|
|
|
static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
|
|
|
|
"Type of pinning for top-level indexes into metadata partitions (see "
|
|
|
|
"`enum PinningTier` in table.h)");
|
|
|
|
|
|
|
|
DEFINE_int32(
|
|
|
|
partition_pinning,
|
|
|
|
static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
|
|
|
|
"Type of pinning for metadata partitions (see `enum PinningTier` in "
|
|
|
|
"table.h)");
|
|
|
|
|
|
|
|
DEFINE_int32(
|
|
|
|
unpartitioned_pinning,
|
|
|
|
static_cast<int32_t>(ROCKSDB_NAMESPACE::PinningTier::kFallback),
|
|
|
|
"Type of pinning for unpartitioned metadata blocks (see `enum PinningTier` "
|
|
|
|
"in table.h)");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(use_clock_cache, false,
|
|
|
|
"Replace default LRU block cache with clock cache.");
|
|
|
|
|
|
|
|
DEFINE_uint64(subcompactions, 1,
|
|
|
|
"Maximum number of subcompactions to divide L0-L1 compactions "
|
|
|
|
"into.");
|
|
|
|
|
|
|
|
DEFINE_uint64(periodic_compaction_seconds, 1000,
|
|
|
|
"Files older than this value will be picked up for compaction.");
|
|
|
|
|
|
|
|
DEFINE_uint64(compaction_ttl, 1000,
|
|
|
|
"Files older than TTL will be compacted to the next level.");
|
|
|
|
|
|
|
|
DEFINE_bool(allow_concurrent_memtable_write, false,
|
|
|
|
"Allow multi-writers to update mem tables in parallel.");
|
|
|
|
|
2021-08-11 03:07:48 +02:00
|
|
|
DEFINE_double(experimental_mempurge_threshold, 0.0,
|
|
|
|
"Maximum estimated useful payload that triggers a "
|
|
|
|
"mempurge process to collect memtable garbage bytes.");
|
2021-07-28 22:27:10 +02:00
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(enable_write_thread_adaptive_yield, true,
|
|
|
|
"Use a yielding spin loop for brief writer thread waits.");
|
|
|
|
|
2019-12-20 19:25:48 +01:00
|
|
|
#ifndef ROCKSDB_LITE
|
2021-02-02 20:39:20 +01:00
|
|
|
// Options for StackableDB-based BlobDB
|
|
|
|
DEFINE_bool(use_blob_db, false, "[Stacked BlobDB] Use BlobDB.");
|
2019-12-20 19:25:48 +01:00
|
|
|
|
2021-02-02 20:39:20 +01:00
|
|
|
DEFINE_uint64(
|
|
|
|
blob_db_min_blob_size,
|
|
|
|
ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().min_blob_size,
|
|
|
|
"[Stacked BlobDB] Smallest blob to store in a file. Blobs "
|
|
|
|
"smaller than this will be inlined with the key in the LSM tree.");
|
2019-12-20 19:25:48 +01:00
|
|
|
|
2021-02-02 20:39:20 +01:00
|
|
|
DEFINE_uint64(
|
|
|
|
blob_db_bytes_per_sync,
|
|
|
|
ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().bytes_per_sync,
|
|
|
|
"[Stacked BlobDB] Sync blob files once per every N bytes written.");
|
2019-12-20 19:25:48 +01:00
|
|
|
|
|
|
|
DEFINE_uint64(blob_db_file_size,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().blob_file_size,
|
2021-02-02 20:39:20 +01:00
|
|
|
"[Stacked BlobDB] Target size of each blob file.");
|
2019-12-20 19:25:48 +01:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_bool(
|
|
|
|
blob_db_enable_gc,
|
|
|
|
ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().enable_garbage_collection,
|
2021-02-02 20:39:20 +01:00
|
|
|
"[Stacked BlobDB] Enable BlobDB garbage collection.");
|
2019-12-20 19:25:48 +01:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_double(
|
|
|
|
blob_db_gc_cutoff,
|
|
|
|
ROCKSDB_NAMESPACE::blob_db::BlobDBOptions().garbage_collection_cutoff,
|
2021-02-02 20:39:20 +01:00
|
|
|
"[Stacked BlobDB] Cutoff ratio for BlobDB garbage collection.");
|
2019-12-20 19:25:48 +01:00
|
|
|
#endif // !ROCKSDB_LITE
|
2021-02-02 20:39:20 +01:00
|
|
|
|
|
|
|
// Options for integrated BlobDB
|
|
|
|
DEFINE_bool(allow_setting_blob_options_dynamically, false,
|
|
|
|
"[Integrated BlobDB] Allow setting blob options dynamically.");
|
|
|
|
|
|
|
|
DEFINE_bool(
|
|
|
|
enable_blob_files,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().enable_blob_files,
|
|
|
|
"[Integrated BlobDB] Enable writing large values to separate blob files.");
|
|
|
|
|
|
|
|
DEFINE_uint64(min_blob_size,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().min_blob_size,
|
|
|
|
"[Integrated BlobDB] The size of the smallest value to be stored "
|
|
|
|
"separately in a blob file.");
|
|
|
|
|
|
|
|
DEFINE_uint64(blob_file_size,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions().blob_file_size,
|
|
|
|
"[Integrated BlobDB] The size limit for blob files.");
|
|
|
|
|
|
|
|
DEFINE_string(blob_compression_type, "none",
|
|
|
|
"[Integrated BlobDB] The compression algorithm to use for large "
|
|
|
|
"values stored in blob files.");
|
|
|
|
|
|
|
|
DEFINE_bool(enable_blob_garbage_collection,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
|
|
|
|
.enable_blob_garbage_collection,
|
|
|
|
"[Integrated BlobDB] Enable blob garbage collection.");
|
|
|
|
|
|
|
|
DEFINE_double(blob_garbage_collection_age_cutoff,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
|
|
|
|
.blob_garbage_collection_age_cutoff,
|
|
|
|
"[Integrated BlobDB] The cutoff in terms of blob file age for "
|
|
|
|
"garbage collection.");
|
2019-12-20 19:25:48 +01:00
|
|
|
|
Make it possible to force the garbage collection of the oldest blob files (#8994)
Summary:
The current BlobDB garbage collection logic works by relocating the valid
blobs from the oldest blob files as they are encountered during compaction,
and cleaning up blob files once they contain nothing but garbage. However,
with sufficiently skewed workloads, it is theoretically possible to end up in a
situation when few or no compactions get scheduled for the SST files that contain
references to the oldest blob files, which can lead to increased space amp due
to the lack of GC.
In order to efficiently handle such workloads, the patch adds a new BlobDB
configuration option called `blob_garbage_collection_force_threshold`,
which signals to BlobDB to schedule targeted compactions for the SST files
that keep alive the oldest batch of blob files if the overall ratio of garbage in
the given blob files meets the threshold *and* all the given blob files are
eligible for GC based on `blob_garbage_collection_age_cutoff`. (For example,
if the new option is set to 0.9, targeted compactions will get scheduled if the
sum of garbage bytes meets or exceeds 90% of the sum of total bytes in the
oldest blob files, assuming all affected blob files are below the age-based cutoff.)
The net result of these targeted compactions is that the valid blobs in the oldest
blob files are relocated and the oldest blob files themselves cleaned up (since
*all* SST files that rely on them get compacted away).
These targeted compactions are similar to periodic compactions in the sense
that they force certain SST files that otherwise would not get picked up to undergo
compaction and also in the sense that instead of merging files from multiple levels,
they target a single file. (Note: such compactions might still include neighboring files
from the same level due to the need of having a "clean cut" boundary but they never
include any files from any other level.)
This functionality is currently only supported with the leveled compaction style
and is inactive by default (since the default value is set to 1.0, i.e. 100%).
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8994
Test Plan: Ran `make check` and tested using `db_bench` and the stress/crash tests.
Reviewed By: riversand963
Differential Revision: D31489850
Pulled By: ltamasi
fbshipit-source-id: 44057d511726a0e2a03c5d9313d7511b3f0c4eab
2021-10-12 03:00:44 +02:00
|
|
|
DEFINE_double(blob_garbage_collection_force_threshold,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
|
|
|
|
.blob_garbage_collection_force_threshold,
|
|
|
|
"[Integrated BlobDB] The threshold for the ratio of garbage in "
|
|
|
|
"the oldest blob files for forcing garbage collection.");
|
|
|
|
|
2021-11-20 02:52:42 +01:00
|
|
|
DEFINE_uint64(blob_compaction_readahead_size,
|
|
|
|
ROCKSDB_NAMESPACE::AdvancedColumnFamilyOptions()
|
|
|
|
.blob_compaction_readahead_size,
|
|
|
|
"[Integrated BlobDB] Compaction readahead for blob files.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
static const bool FLAGS_subcompactions_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_subcompactions, &ValidateUint32Range);
|
|
|
|
|
|
|
|
static bool ValidateInt32Positive(const char* flagname, int32_t value) {
|
|
|
|
if (value < 0) {
|
|
|
|
fprintf(stderr, "Invalid value for --%s: %d, must be >=0\n", flagname,
|
|
|
|
value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
DEFINE_int32(reopen, 10, "Number of times database reopens");
|
|
|
|
static const bool FLAGS_reopen_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_reopen, &ValidateInt32Positive);
|
|
|
|
|
2019-12-10 17:38:23 +01:00
|
|
|
DEFINE_double(bloom_bits, 10,
|
|
|
|
"Bloom filter bits per key. "
|
|
|
|
"Negative means use default settings.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_bool(use_block_based_filter, false,
|
|
|
|
"use block based filter"
|
|
|
|
"instead of full filter for block based table");
|
|
|
|
|
Add Bloom/Ribbon hybrid API support (#8679)
Summary:
This is essentially resurrection and fixing of the part of
https://github.com/facebook/rocksdb/issues/8198 that was reverted in https://github.com/facebook/rocksdb/issues/8212, using data added in https://github.com/facebook/rocksdb/issues/8246. Basically,
when configuring Ribbon filter, you can specify an LSM level before which
Bloom will be used instead of Ribbon. But Bloom is only considered for
Leveled and Universal compaction styles and file going into a known LSM
level. This way, SST file writer, FIFO compaction, etc. use Ribbon filter as
you would expect with NewRibbonFilterPolicy.
So that this can be controlled with a single int value and so that flushes
can be distinguished from intra-L0, we consider flush to go to level -1 for
the purposes of this option. (Explained in API comment.)
I also expect the most common and recommended Ribbon configuration to
use Bloom during flush, to minimize slowing down writes and because according
to my estimates, Ribbon only pays off if the structure lives in memory for
more than an hour. Thus, I have changed the default for NewRibbonFilterPolicy
to be this mild hybrid configuration. I don't really want to add something like
NewHybridFilterPolicy because at least the mild hybrid configuration (Bloom for
flush, Ribbon otherwise) should be considered a natural choice.
C APIs also updated, but because they don't support overloading,
rocksdb_filterpolicy_create_ribbon is kept pure ribbon for clarity and
rocksdb_filterpolicy_create_ribbon_hybrid must be called for a hybrid
configuration. While touching C API, I changed bits per key options from
int to double.
BuiltinFilterPolicy is needed so that LevelThresholdFilterPolicy doesn't inherit
unused fields from BloomFilterPolicy.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8679
Test Plan: new + updated tests, including crash test
Reviewed By: jay-zhuang
Differential Revision: D30445797
Pulled By: pdillinger
fbshipit-source-id: 6f5aeddfd6d79f7e55493b563c2d1d2d568892e1
2021-08-21 02:59:24 +02:00
|
|
|
DEFINE_int32(
|
|
|
|
ribbon_starting_level, 999,
|
|
|
|
"Use Bloom filter on levels below specified and Ribbon beginning on level "
|
|
|
|
"specified. Flush is considered level -1. 999 or more -> always Bloom. 0 "
|
|
|
|
"-> Ribbon except Bloom for flush. -1 -> always Ribbon.");
|
Experimental (production candidate) SST schema for Ribbon filter (#7658)
Summary:
Added experimental public API for Ribbon filter:
NewExperimentalRibbonFilterPolicy(). This experimental API will
take a "Bloom equivalent" bits per key, and configure the Ribbon
filter for the same FP rate as Bloom would have but ~30% space
savings. (Note: optimize_filters_for_memory is not yet implemented
for Ribbon filter. That can be added with no effect on schema.)
Internally, the Ribbon filter is configured using a "one_in_fp_rate"
value, which is 1 over desired FP rate. For example, use 100 for 1%
FP rate. I'm expecting this will be used in the future for configuring
Bloom-like filters, as I expect people to more commonly hold constant
the filter accuracy and change the space vs. time trade-off, rather than
hold constant the space (per key) and change the accuracy vs. time
trade-off, though we might make that available.
### Benchmarking
```
$ ./filter_bench -impl=2 -quick -m_keys_total_max=200 -average_keys_per_filter=100000 -net_includes_hashing
Building...
Build avg ns/key: 34.1341
Number of filters: 1993
Total size (MB): 238.488
Reported total allocated memory (MB): 262.875
Reported internal fragmentation: 10.2255%
Bits/key stored: 10.0029
----------------------------
Mixed inside/outside queries...
Single filter net ns/op: 18.7508
Random filter net ns/op: 258.246
Average FP rate %: 0.968672
----------------------------
Done. (For more info, run with -legend or -help.)
$ ./filter_bench -impl=3 -quick -m_keys_total_max=200 -average_keys_per_filter=100000 -net_includes_hashing
Building...
Build avg ns/key: 130.851
Number of filters: 1993
Total size (MB): 168.166
Reported total allocated memory (MB): 183.211
Reported internal fragmentation: 8.94626%
Bits/key stored: 7.05341
----------------------------
Mixed inside/outside queries...
Single filter net ns/op: 58.4523
Random filter net ns/op: 363.717
Average FP rate %: 0.952978
----------------------------
Done. (For more info, run with -legend or -help.)
```
168.166 / 238.488 = 0.705 -> 29.5% space reduction
130.851 / 34.1341 = 3.83x construction time for this Ribbon filter vs. lastest Bloom filter (could make that as little as about 2.5x for less space reduction)
### Working around a hashing "flaw"
bloom_test discovered a flaw in the simple hashing applied in
StandardHasher when num_starts == 1 (num_slots == 128), showing an
excessively high FP rate. The problem is that when many entries, on the
order of number of hash bits or kCoeffBits, are associated with the same
start location, the correlation between the CoeffRow and ResultRow (for
efficiency) can lead to a solution that is "universal," or nearly so, for
entries mapping to that start location. (Normally, variance in start
location breaks the effective association between CoeffRow and
ResultRow; the same value for CoeffRow is effectively different if start
locations are different.) Without kUseSmash and with num_starts > 1 (thus
num_starts ~= num_slots), this flaw should be completely irrelevant. Even
with 10M slots, the chances of a single slot having just 16 (or more)
entries map to it--not enough to cause an FP problem, which would be local
to that slot if it happened--is 1 in millions. This spreadsheet formula
shows that: =1/(10000000*(1 - POISSON(15, 1, TRUE)))
As kUseSmash==false (the setting for Standard128RibbonBitsBuilder) is
intended for CPU efficiency of filters with many more entries/slots than
kCoeffBits, a very reasonable work-around is to disallow num_starts==1
when !kUseSmash, by making the minimum non-zero number of slots
2*kCoeffBits. This is the work-around I've applied. This also means that
the new Ribbon filter schema (Standard128RibbonBitsBuilder) is not
space-efficient for less than a few hundred entries. Because of this, I
have made it fall back on constructing a Bloom filter, under existing
schema, when that is more space efficient for small filters. (We can
change this in the future if we want.)
TODO: better unit tests for this case in ribbon_test, and probably
update StandardHasher for kUseSmash case so that it can scale nicely to
small filters.
### Other related changes
* Add Ribbon filter to stress/crash test
* Add Ribbon filter to filter_bench as -impl=3
* Add option string support, as in "filter_policy=experimental_ribbon:5.678;"
where 5.678 is the Bloom equivalent bits per key.
* Rename internal mode BloomFilterPolicy::kAuto to kAutoBloom
* Add a general BuiltinFilterBitsBuilder::CalculateNumEntry based on
binary searching CalculateSpace (inefficient), so that subclasses
(especially experimental ones) don't have to provide an efficient
implementation inverting CalculateSpace.
* Minor refactor FastLocalBloomBitsBuilder for new base class
XXH3pFilterBitsBuilder shared with new Standard128RibbonBitsBuilder,
which allows the latter to fall back on Bloom construction in some
extreme cases.
* Mostly updated bloom_test for Ribbon filter, though a test like
FullBloomTest::Schema is a next TODO to ensure schema stability
(in case this becomes production-ready schema as it is).
* Add some APIs to ribbon_impl.h for configuring Ribbon filters.
Although these are reasonably covered by bloom_test, TODO more unit
tests in ribbon_test
* Added a "tool" FindOccupancyForSuccessRate to ribbon_test to get data
for constructing the linear approximations in GetNumSlotsFor95PctSuccess.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7658
Test Plan:
Some unit tests updated but other testing is left TODO. This
is considered experimental but laying down schema compatibility as early
as possible in case it proves production-quality. Also tested in
stress/crash test.
Reviewed By: jay-zhuang
Differential Revision: D24899349
Pulled By: pdillinger
fbshipit-source-id: 9715f3e6371c959d923aea8077c9423c7a9f82b8
2020-11-13 05:45:02 +01:00
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(partition_filters, false,
|
|
|
|
"use partitioned filters "
|
|
|
|
"for block-based table");
|
|
|
|
|
Minimize memory internal fragmentation for Bloom filters (#6427)
Summary:
New experimental option BBTO::optimize_filters_for_memory builds
filters that maximize their use of "usable size" from malloc_usable_size,
which is also used to compute block cache charges.
Rather than always "rounding up," we track state in the
BloomFilterPolicy object to mix essentially "rounding down" and
"rounding up" so that the average FP rate of all generated filters is
the same as without the option. (YMMV as heavily accessed filters might
be unluckily lower accuracy.)
Thus, the option near-minimizes what the block cache considers as
"memory used" for a given target Bloom filter false positive rate and
Bloom filter implementation. There are no forward or backward
compatibility issues with this change, though it only works on the
format_version=5 Bloom filter.
With Jemalloc, we see about 10% reduction in memory footprint (and block
cache charge) for Bloom filters, but 1-2% increase in storage footprint,
due to encoding efficiency losses (FP rate is non-linear with bits/key).
Why not weighted random round up/down rather than state tracking? By
only requiring malloc_usable_size, we don't actually know what the next
larger and next smaller usable sizes for the allocator are. We pick a
requested size, accept and use whatever usable size it has, and use the
difference to inform our next choice. This allows us to narrow in on the
right balance without tracking/predicting usable sizes.
Why not weight history of generated filter false positive rates by
number of keys? This could lead to excess skew in small filters after
generating a large filter.
Results from filter_bench with jemalloc (irrelevant details omitted):
(normal keys/filter, but high variance)
$ ./filter_bench -quick -impl=2 -average_keys_per_filter=30000 -vary_key_count_ratio=0.9
Build avg ns/key: 29.6278
Number of filters: 5516
Total size (MB): 200.046
Reported total allocated memory (MB): 220.597
Reported internal fragmentation: 10.2732%
Bits/key stored: 10.0097
Average FP rate %: 0.965228
$ ./filter_bench -quick -impl=2 -average_keys_per_filter=30000 -vary_key_count_ratio=0.9 -optimize_filters_for_memory
Build avg ns/key: 30.5104
Number of filters: 5464
Total size (MB): 200.015
Reported total allocated memory (MB): 200.322
Reported internal fragmentation: 0.153709%
Bits/key stored: 10.1011
Average FP rate %: 0.966313
(very few keys / filter, optimization not as effective due to ~59 byte
internal fragmentation in blocked Bloom filter representation)
$ ./filter_bench -quick -impl=2 -average_keys_per_filter=1000 -vary_key_count_ratio=0.9
Build avg ns/key: 29.5649
Number of filters: 162950
Total size (MB): 200.001
Reported total allocated memory (MB): 224.624
Reported internal fragmentation: 12.3117%
Bits/key stored: 10.2951
Average FP rate %: 0.821534
$ ./filter_bench -quick -impl=2 -average_keys_per_filter=1000 -vary_key_count_ratio=0.9 -optimize_filters_for_memory
Build avg ns/key: 31.8057
Number of filters: 159849
Total size (MB): 200
Reported total allocated memory (MB): 208.846
Reported internal fragmentation: 4.42297%
Bits/key stored: 10.4948
Average FP rate %: 0.811006
(high keys/filter)
$ ./filter_bench -quick -impl=2 -average_keys_per_filter=1000000 -vary_key_count_ratio=0.9
Build avg ns/key: 29.7017
Number of filters: 164
Total size (MB): 200.352
Reported total allocated memory (MB): 221.5
Reported internal fragmentation: 10.5552%
Bits/key stored: 10.0003
Average FP rate %: 0.969358
$ ./filter_bench -quick -impl=2 -average_keys_per_filter=1000000 -vary_key_count_ratio=0.9 -optimize_filters_for_memory
Build avg ns/key: 30.7131
Number of filters: 160
Total size (MB): 200.928
Reported total allocated memory (MB): 200.938
Reported internal fragmentation: 0.00448054%
Bits/key stored: 10.1852
Average FP rate %: 0.963387
And from db_bench (block cache) with jemalloc:
$ ./db_bench -db=/dev/shm/dbbench.no_optimize -benchmarks=fillrandom -format_version=5 -value_size=90 -bloom_bits=10 -num=2000000 -threads=8 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=false
$ ./db_bench -db=/dev/shm/dbbench -benchmarks=fillrandom -format_version=5 -value_size=90 -bloom_bits=10 -num=2000000 -threads=8 -optimize_filters_for_memory -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=false
$ (for FILE in /dev/shm/dbbench.no_optimize/*.sst; do ./sst_dump --file=$FILE --show_properties | grep 'filter block' ; done) | awk '{ t += $4; } END { print t; }'
17063835
$ (for FILE in /dev/shm/dbbench/*.sst; do ./sst_dump --file=$FILE --show_properties | grep 'filter block' ; done) | awk '{ t += $4; } END { print t; }'
17430747
$ #^ 2.1% additional filter storage
$ ./db_bench -db=/dev/shm/dbbench.no_optimize -use_existing_db -benchmarks=readrandom,stats -statistics -bloom_bits=10 -num=2000000 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=false -duration=10 -cache_index_and_filter_blocks -cache_size=1000000000
rocksdb.block.cache.index.add COUNT : 33
rocksdb.block.cache.index.bytes.insert COUNT : 8440400
rocksdb.block.cache.filter.add COUNT : 33
rocksdb.block.cache.filter.bytes.insert COUNT : 21087528
rocksdb.bloom.filter.useful COUNT : 4963889
rocksdb.bloom.filter.full.positive COUNT : 1214081
rocksdb.bloom.filter.full.true.positive COUNT : 1161999
$ #^ 1.04 % observed FP rate
$ ./db_bench -db=/dev/shm/dbbench -use_existing_db -benchmarks=readrandom,stats -statistics -bloom_bits=10 -num=2000000 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=false -optimize_filters_for_memory -duration=10 -cache_index_and_filter_blocks -cache_size=1000000000
rocksdb.block.cache.index.add COUNT : 33
rocksdb.block.cache.index.bytes.insert COUNT : 8448592
rocksdb.block.cache.filter.add COUNT : 33
rocksdb.block.cache.filter.bytes.insert COUNT : 18220328
rocksdb.bloom.filter.useful COUNT : 5360933
rocksdb.bloom.filter.full.positive COUNT : 1321315
rocksdb.bloom.filter.full.true.positive COUNT : 1262999
$ #^ 1.08 % observed FP rate, 13.6% less memory usage for filters
(Due to specific key density, this example tends to generate filters that are "worse than average" for internal fragmentation. "Better than average" cases can show little or no improvement.)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6427
Test Plan: unit test added, 'make check' with gcc, clang and valgrind
Reviewed By: siying
Differential Revision: D22124374
Pulled By: pdillinger
fbshipit-source-id: f3e3aa152f9043ddf4fae25799e76341d0d8714e
2020-06-22 22:30:57 +02:00
|
|
|
DEFINE_bool(
|
|
|
|
optimize_filters_for_memory,
|
|
|
|
ROCKSDB_NAMESPACE::BlockBasedTableOptions().optimize_filters_for_memory,
|
|
|
|
"Minimize memory footprint of filters");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(
|
|
|
|
index_type,
|
2020-02-20 21:07:53 +01:00
|
|
|
static_cast<int32_t>(
|
|
|
|
ROCKSDB_NAMESPACE::BlockBasedTableOptions::kBinarySearch),
|
2019-12-09 08:49:32 +01:00
|
|
|
"Type of block-based table index (see `enum IndexType` in table.h)");
|
|
|
|
|
|
|
|
DEFINE_string(db, "", "Use the db with the following name.");
|
|
|
|
|
|
|
|
DEFINE_string(secondaries_base, "",
|
|
|
|
"Use this path as the base path for secondary instances.");
|
|
|
|
|
2019-12-20 17:46:52 +01:00
|
|
|
DEFINE_bool(test_secondary, false, "Test secondary instance.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_string(
|
2021-09-28 23:12:23 +02:00
|
|
|
expected_values_dir, "",
|
|
|
|
"Dir where file with array of expected uint32_t values will be stored. If "
|
2019-12-09 08:49:32 +01:00
|
|
|
"provided and non-empty, the DB state will be verified against these "
|
|
|
|
"values after recovery. --max_key and --column_family must be kept the "
|
|
|
|
"same across invocations of this program that use the same "
|
2021-10-12 01:22:10 +02:00
|
|
|
"--expected_values_dir. See --seed and --nooverwritepercent for further "
|
|
|
|
"requirements.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_bool(verify_checksum, false,
|
|
|
|
"Verify checksum for every block read from storage");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_bool(mmap_read, ROCKSDB_NAMESPACE::Options().allow_mmap_reads,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Allow reads to occur via mmap-ing files");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_bool(mmap_write, ROCKSDB_NAMESPACE::Options().allow_mmap_writes,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Allow writes to occur via mmap-ing files");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_bool(use_direct_reads, ROCKSDB_NAMESPACE::Options().use_direct_reads,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Use O_DIRECT for reading data");
|
|
|
|
|
|
|
|
DEFINE_bool(use_direct_io_for_flush_and_compaction,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().use_direct_io_for_flush_and_compaction,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Use O_DIRECT for writing data");
|
|
|
|
|
2020-04-25 08:58:13 +02:00
|
|
|
DEFINE_bool(mock_direct_io, false,
|
|
|
|
"Mock direct IO by not using O_DIRECT for direct IO read");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(statistics, false, "Create database statistics");
|
|
|
|
|
|
|
|
DEFINE_bool(sync, false, "Sync all writes to disk");
|
|
|
|
|
|
|
|
DEFINE_bool(use_fsync, false, "If true, issue fsync instead of fdatasync");
|
|
|
|
|
|
|
|
DEFINE_int32(kill_random_test, 0,
|
|
|
|
"If non-zero, kill at various points in source code with "
|
|
|
|
"probability 1/this");
|
|
|
|
static const bool FLAGS_kill_random_test_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_kill_random_test, &ValidateInt32Positive);
|
|
|
|
|
2020-06-20 00:26:05 +02:00
|
|
|
DEFINE_string(kill_exclude_prefixes, "",
|
2019-12-09 08:49:32 +01:00
|
|
|
"If non-empty, kill points with prefix in the list given will be"
|
|
|
|
" skipped. Items are comma-separated.");
|
2020-06-20 00:26:05 +02:00
|
|
|
extern std::vector<std::string> rocksdb_kill_exclude_prefixes;
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_bool(disable_wal, false, "If true, do not write WAL for write.");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_uint64(recycle_log_file_num,
|
|
|
|
ROCKSDB_NAMESPACE::Options().recycle_log_file_num,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Number of old WAL files to keep around for later recycling");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_int64(target_file_size_base,
|
|
|
|
ROCKSDB_NAMESPACE::Options().target_file_size_base,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Target level-1 file size for compaction");
|
|
|
|
|
|
|
|
DEFINE_int32(target_file_size_multiplier, 1,
|
|
|
|
"A multiplier to compute target level-N file size (N >= 2)");
|
|
|
|
|
|
|
|
DEFINE_uint64(max_bytes_for_level_base,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().max_bytes_for_level_base,
|
2019-12-09 08:49:32 +01:00
|
|
|
"Max bytes for level-1");
|
|
|
|
|
|
|
|
DEFINE_double(max_bytes_for_level_multiplier, 2,
|
|
|
|
"A multiplier to compute max bytes for level-N (N >= 2)");
|
|
|
|
|
|
|
|
DEFINE_int32(range_deletion_width, 10,
|
|
|
|
"The width of the range deletion intervals.");
|
|
|
|
|
|
|
|
DEFINE_uint64(rate_limiter_bytes_per_sec, 0, "Set options.rate_limiter value.");
|
|
|
|
|
|
|
|
DEFINE_bool(rate_limit_bg_reads, false,
|
|
|
|
"Use options.rate_limiter on compaction reads");
|
|
|
|
|
2020-02-26 01:43:33 +01:00
|
|
|
DEFINE_uint64(sst_file_manager_bytes_per_sec, 0,
|
|
|
|
"Set `Options::sst_file_manager` to delete at this rate. By "
|
|
|
|
"default the deletion rate is unbounded.");
|
|
|
|
|
|
|
|
DEFINE_uint64(sst_file_manager_bytes_per_truncate, 0,
|
|
|
|
"Set `Options::sst_file_manager` to delete in chunks of this "
|
|
|
|
"many bytes. By default whole files will be deleted.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(use_txn, false,
|
|
|
|
"Use TransactionDB. Currently the default write policy is "
|
|
|
|
"TxnDBWritePolicy::WRITE_PREPARED");
|
|
|
|
|
2019-12-12 19:34:52 +01:00
|
|
|
DEFINE_uint64(txn_write_policy, 0,
|
|
|
|
"The transaction write policy. Default is "
|
|
|
|
"TxnDBWritePolicy::WRITE_COMMITTED. Note that this should not be "
|
|
|
|
"changed accross crashes.");
|
|
|
|
|
2019-12-13 19:23:01 +01:00
|
|
|
DEFINE_bool(unordered_write, false,
|
|
|
|
"Turn on the unordered_write feature. This options is currently "
|
|
|
|
"tested only in combination with use_txn=true and "
|
|
|
|
"txn_write_policy=TxnDBWritePolicy::WRITE_PREPARED.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(backup_one_in, 0,
|
|
|
|
"If non-zero, then CreateNewBackup() will be called once for "
|
|
|
|
"every N operations on average. 0 indicates CreateNewBackup() "
|
|
|
|
"is disabled.");
|
|
|
|
|
Fix, enable, and enhance backup/restore in db_stress (#7348)
Summary:
Although added to db_stress, testing of backup/restore
was never integrated into the crash test, originally concerned about
performance. I've enabled it now and to address the peformance concern,
testing backup/restore is always skipped once the db exceeds a certain
size threshold, default 100MB. This should provide sufficient
opportunity for testing BackupEngine without bogging down everything
else with heavier and heavier operations.
Also fixed backup/restore in db_stress by making sure PurgeOldBackups
can remove manifest files, which are normally kept around for db_stress.
Added more coverage of backup options, and up to three backups being
saved in one backup directory (in some cases).
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7348
Test Plan:
ran 'make blackbox_crash_test' for a while, with heightened
probabilitly of taking backups (1/10k). Also confirmed with some debug
output that the code is being covered, TestBackupRestore only takes
a few seconds to complete when triggered, and even at 1/10k and ~50MB
database, there's <,~ 1 thread testing backups at any time.
Reviewed By: ajkr
Differential Revision: D23510835
Pulled By: pdillinger
fbshipit-source-id: b6b8735591808141f81f10773ac31634cf03b6c0
2020-09-04 05:11:45 +02:00
|
|
|
DEFINE_uint64(backup_max_size, 100 * 1024 * 1024,
|
|
|
|
"If non-zero, skip checking backup/restore when DB size in "
|
|
|
|
"bytes exceeds this setting.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(checkpoint_one_in, 0,
|
|
|
|
"If non-zero, then CreateCheckpoint() will be called once for "
|
|
|
|
"every N operations on average. 0 indicates CreateCheckpoint() "
|
|
|
|
"is disabled.");
|
|
|
|
|
|
|
|
DEFINE_int32(ingest_external_file_one_in, 0,
|
|
|
|
"If non-zero, then IngestExternalFile() will be called once for "
|
|
|
|
"every N operations on average. 0 indicates IngestExternalFile() "
|
|
|
|
"is disabled.");
|
|
|
|
|
|
|
|
DEFINE_int32(ingest_external_file_width, 1000,
|
|
|
|
"The width of the ingested external files.");
|
|
|
|
|
|
|
|
DEFINE_int32(compact_files_one_in, 0,
|
|
|
|
"If non-zero, then CompactFiles() will be called once for every N "
|
|
|
|
"operations on average. 0 indicates CompactFiles() is disabled.");
|
|
|
|
|
|
|
|
DEFINE_int32(compact_range_one_in, 0,
|
|
|
|
"If non-zero, then CompactRange() will be called once for every N "
|
|
|
|
"operations on average. 0 indicates CompactRange() is disabled.");
|
|
|
|
|
2020-08-11 01:16:19 +02:00
|
|
|
DEFINE_int32(mark_for_compaction_one_file_in, 0,
|
|
|
|
"A `TablePropertiesCollectorFactory` will be registered, which "
|
|
|
|
"creates a `TablePropertiesCollector` with `NeedCompact()` "
|
|
|
|
"returning true once for every N files on average. 0 or negative "
|
|
|
|
"mean `NeedCompact()` always returns false.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(flush_one_in, 0,
|
|
|
|
"If non-zero, then Flush() will be called once for every N ops "
|
|
|
|
"on average. 0 indicates calls to Flush() are disabled.");
|
|
|
|
|
2019-12-11 00:45:25 +01:00
|
|
|
DEFINE_int32(pause_background_one_in, 0,
|
|
|
|
"If non-zero, then PauseBackgroundWork()+Continue will be called "
|
|
|
|
"once for every N ops on average. 0 disables.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_int32(compact_range_width, 10000,
|
|
|
|
"The width of the ranges passed to CompactRange().");
|
|
|
|
|
|
|
|
DEFINE_int32(acquire_snapshot_one_in, 0,
|
|
|
|
"If non-zero, then acquires a snapshot once every N operations on "
|
|
|
|
"average.");
|
|
|
|
|
|
|
|
DEFINE_bool(compare_full_db_state_snapshot, false,
|
|
|
|
"If set we compare state of entire db (in one of the threads) with"
|
|
|
|
"each snapshot.");
|
|
|
|
|
|
|
|
DEFINE_uint64(snapshot_hold_ops, 0,
|
|
|
|
"If non-zero, then releases snapshots N operations after they're "
|
|
|
|
"acquired.");
|
|
|
|
|
2019-12-15 00:17:05 +01:00
|
|
|
DEFINE_bool(long_running_snapshots, false,
|
|
|
|
"If set, hold on some some snapshots for much longer time.");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_bool(use_multiget, false,
|
|
|
|
"If set, use the batched MultiGet API for reads");
|
|
|
|
|
|
|
|
static bool ValidateInt32Percent(const char* flagname, int32_t value) {
|
|
|
|
if (value < 0 || value > 100) {
|
|
|
|
fprintf(stderr, "Invalid value for --%s: %d, 0<= pct <=100 \n", flagname,
|
|
|
|
value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_int32(readpercent, 10,
|
|
|
|
"Ratio of reads to total workload (expressed as a percentage)");
|
|
|
|
static const bool FLAGS_readpercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_readpercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_int32(prefixpercent, 20,
|
|
|
|
"Ratio of prefix iterators to total workload (expressed as a"
|
|
|
|
" percentage)");
|
|
|
|
static const bool FLAGS_prefixpercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_prefixpercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_int32(writepercent, 45,
|
|
|
|
"Ratio of writes to total workload (expressed as a percentage)");
|
|
|
|
static const bool FLAGS_writepercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_writepercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_int32(delpercent, 15,
|
|
|
|
"Ratio of deletes to total workload (expressed as a percentage)");
|
|
|
|
static const bool FLAGS_delpercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_delpercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_int32(delrangepercent, 0,
|
|
|
|
"Ratio of range deletions to total workload (expressed as a "
|
|
|
|
"percentage). Cannot be used with test_batches_snapshots");
|
|
|
|
static const bool FLAGS_delrangepercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_delrangepercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_int32(nooverwritepercent, 60,
|
|
|
|
"Ratio of keys without overwrite to total workload (expressed as "
|
2021-10-12 01:22:10 +02:00
|
|
|
"a percentage). When --expected_values_dir is nonempty, must "
|
|
|
|
"keep this value constant across invocations.");
|
2019-12-09 08:49:32 +01:00
|
|
|
static const bool FLAGS_nooverwritepercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_nooverwritepercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_int32(iterpercent, 10,
|
|
|
|
"Ratio of iterations to total workload"
|
|
|
|
" (expressed as a percentage)");
|
|
|
|
static const bool FLAGS_iterpercent_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_iterpercent, &ValidateInt32Percent);
|
|
|
|
|
|
|
|
DEFINE_uint64(num_iterations, 10, "Number of iterations per MultiIterate run");
|
|
|
|
static const bool FLAGS_num_iterations_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_num_iterations, &ValidateUint32Range);
|
|
|
|
|
|
|
|
DEFINE_string(compression_type, "snappy",
|
|
|
|
"Algorithm to use to compress the database");
|
|
|
|
|
|
|
|
DEFINE_int32(compression_max_dict_bytes, 0,
|
|
|
|
"Maximum size of dictionary used to prime the compression "
|
|
|
|
"library.");
|
|
|
|
|
|
|
|
DEFINE_int32(compression_zstd_max_train_bytes, 0,
|
|
|
|
"Maximum size of training data passed to zstd's dictionary "
|
|
|
|
"trainer.");
|
|
|
|
|
2020-04-30 19:46:54 +02:00
|
|
|
DEFINE_int32(compression_parallel_threads, 1,
|
|
|
|
"Number of threads for parallel compression.");
|
|
|
|
|
Limit buffering for collecting samples for compression dictionary (#7970)
Summary:
For dictionary compression, we need to collect some representative samples of the data to be compressed, which we use to either generate or train (when `CompressionOptions::zstd_max_train_bytes > 0`) a dictionary. Previously, the strategy was to buffer all the data blocks during flush, and up to the target file size during compaction. That strategy allowed us to randomly pick samples from as wide a range as possible that'd be guaranteed to land in a single output file.
However, some users try to make huge files in memory-constrained environments, where this strategy can cause OOM. This PR introduces an option, `CompressionOptions::max_dict_buffer_bytes`, that limits how much data blocks are buffered before we switch to unbuffered mode (which means creating the per-SST dictionary, writing out the buffered data, and compressing/writing new blocks as soon as they are built). It is not strict as we currently buffer more than just data blocks -- also keys are buffered. But it does make a step towards giving users predictable memory usage.
Related changes include:
- Changed sampling for dictionary compression to select unique data blocks when there is limited availability of data blocks
- Made use of `BlockBuilder::SwapAndReset()` to save an allocation+memcpy when buffering data blocks for building a dictionary
- Changed `ParseBoolean()` to accept an input containing characters after the boolean. This is necessary since, with this PR, a value for `CompressionOptions::enabled` is no longer necessarily the final component in the `CompressionOptions` string.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7970
Test Plan:
- updated `CompressionOptions` unit tests to verify limit is respected (to the extent expected in the current implementation) in various scenarios of flush/compaction to bottommost/non-bottommost level
- looked at jemalloc heap profiles right before and after switching to unbuffered mode during flush/compaction. Verified memory usage in buffering is proportional to the limit set.
Reviewed By: pdillinger
Differential Revision: D26467994
Pulled By: ajkr
fbshipit-source-id: 3da4ef9fba59974e4ef40e40c01611002c861465
2021-02-19 23:06:59 +01:00
|
|
|
DEFINE_uint64(compression_max_dict_buffer_bytes, 0,
|
|
|
|
"Buffering limit for SST file data to sample for dictionary "
|
|
|
|
"compression.");
|
|
|
|
|
2019-12-21 01:13:19 +01:00
|
|
|
DEFINE_string(bottommost_compression_type, "disable",
|
|
|
|
"Algorithm to use to compress bottommost level of the database. "
|
|
|
|
"\"disable\" means disabling the feature");
|
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
DEFINE_string(checksum_type, "kCRC32c", "Algorithm to use to checksum blocks");
|
|
|
|
|
2020-08-17 20:51:45 +02:00
|
|
|
DEFINE_string(hdfs, "",
|
|
|
|
"Name of hdfs environment. Mutually exclusive with"
|
|
|
|
" --env_uri and --fs_uri.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
2020-08-17 20:51:45 +02:00
|
|
|
DEFINE_string(
|
|
|
|
env_uri, "",
|
|
|
|
"URI for env lookup. Mutually exclusive with --hdfs and --fs_uri");
|
|
|
|
|
|
|
|
DEFINE_string(fs_uri, "",
|
|
|
|
"URI for registry Filesystem lookup. Mutually exclusive"
|
|
|
|
" with --hdfs and --env_uri."
|
|
|
|
" Creates a default environment with the specified filesystem.");
|
2019-12-09 08:49:32 +01:00
|
|
|
|
|
|
|
DEFINE_uint64(ops_per_thread, 1200000, "Number of operations per thread.");
|
|
|
|
static const bool FLAGS_ops_per_thread_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_ops_per_thread, &ValidateUint32Range);
|
|
|
|
|
|
|
|
DEFINE_uint64(log2_keys_per_lock, 2, "Log2 of number of keys per lock");
|
|
|
|
static const bool FLAGS_log2_keys_per_lock_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_log2_keys_per_lock, &ValidateUint32Range);
|
|
|
|
|
|
|
|
DEFINE_uint64(max_manifest_file_size, 16384, "Maximum size of a MANIFEST file");
|
|
|
|
|
|
|
|
DEFINE_bool(in_place_update, false, "On true, does inplace update in memtable");
|
|
|
|
|
|
|
|
DEFINE_int32(secondary_catch_up_one_in, 0,
|
|
|
|
"If non-zero, the secondaries attemp to catch up with the primary "
|
|
|
|
"once for every N operations on average. 0 indicates the "
|
|
|
|
"secondaries do not try to catch up after open.");
|
|
|
|
|
|
|
|
DEFINE_string(memtablerep, "skip_list", "");
|
|
|
|
|
|
|
|
inline static bool ValidatePrefixSize(const char* flagname, int32_t value) {
|
|
|
|
if (value < -1 || value > 8) {
|
|
|
|
fprintf(stderr, "Invalid value for --%s: %d. -1 <= PrefixSize <= 8\n",
|
|
|
|
flagname, value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
DEFINE_int32(prefix_size, 7,
|
|
|
|
"Control the prefix size for HashSkipListRep. "
|
|
|
|
"-1 is disabled.");
|
|
|
|
static const bool FLAGS_prefix_size_dummy __attribute__((__unused__)) =
|
|
|
|
RegisterFlagValidator(&FLAGS_prefix_size, &ValidatePrefixSize);
|
|
|
|
|
|
|
|
DEFINE_bool(use_merge, false,
|
|
|
|
"On true, replaces all writes with a Merge "
|
|
|
|
"that behaves like a Put");
|
|
|
|
|
|
|
|
DEFINE_bool(use_full_merge_v1, false,
|
|
|
|
"On true, use a merge operator that implement the deprecated "
|
|
|
|
"version of FullMerge");
|
2019-12-11 06:53:43 +01:00
|
|
|
|
|
|
|
DEFINE_int32(sync_wal_one_in, 0,
|
|
|
|
"If non-zero, then SyncWAL() will be called once for every N ops "
|
|
|
|
"on average. 0 indicates that calls to SyncWAL() are disabled.");
|
2019-12-17 00:24:26 +01:00
|
|
|
|
|
|
|
DEFINE_bool(avoid_unnecessary_blocking_io,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().avoid_unnecessary_blocking_io,
|
2019-12-17 00:24:26 +01:00
|
|
|
"If true, some expensive cleaning up operations will be moved from "
|
|
|
|
"user reads to high-pri background threads.");
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
DEFINE_bool(write_dbid_to_manifest,
|
|
|
|
ROCKSDB_NAMESPACE::Options().write_dbid_to_manifest,
|
2019-12-17 00:24:26 +01:00
|
|
|
"Write DB_ID to manifest");
|
|
|
|
|
2020-04-16 21:09:18 +02:00
|
|
|
DEFINE_bool(avoid_flush_during_recovery,
|
|
|
|
ROCKSDB_NAMESPACE::Options().avoid_flush_during_recovery,
|
|
|
|
"Avoid flush during recovery");
|
|
|
|
|
2019-12-17 00:24:26 +01:00
|
|
|
DEFINE_uint64(max_write_batch_group_size_bytes,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().max_write_batch_group_size_bytes,
|
2019-12-17 00:24:26 +01:00
|
|
|
"Max write batch group size");
|
|
|
|
|
|
|
|
DEFINE_bool(level_compaction_dynamic_level_bytes,
|
2020-02-20 21:07:53 +01:00
|
|
|
ROCKSDB_NAMESPACE::Options().level_compaction_dynamic_level_bytes,
|
2019-12-17 00:24:26 +01:00
|
|
|
"Use dynamic level");
|
|
|
|
|
2019-12-18 05:43:06 +01:00
|
|
|
DEFINE_int32(verify_checksum_one_in, 0,
|
|
|
|
"If non-zero, then DB::VerifyChecksum() will be called to do"
|
|
|
|
" checksum verification of all the files in the database once for"
|
|
|
|
" every N ops on average. 0 indicates that calls to"
|
|
|
|
" VerifyChecksum() are disabled.");
|
2019-12-20 17:46:52 +01:00
|
|
|
DEFINE_int32(verify_db_one_in, 0,
|
|
|
|
"If non-zero, call VerifyDb() once for every N ops. 0 indicates "
|
|
|
|
"that VerifyDb() will not be called in OperateDb(). Note that "
|
|
|
|
"enabling this can slow down tests.");
|
|
|
|
|
|
|
|
DEFINE_int32(continuous_verification_interval, 1000,
|
|
|
|
"While test is running, verify db every N milliseconds. 0 "
|
|
|
|
"disables continuous verification.");
|
2019-12-21 06:42:19 +01:00
|
|
|
|
|
|
|
DEFINE_int32(approximate_size_one_in, 64,
|
|
|
|
"If non-zero, DB::GetApproximateSizes() will be called against"
|
|
|
|
" random key ranges.");
|
2020-04-11 02:18:56 +02:00
|
|
|
|
|
|
|
DEFINE_int32(read_fault_one_in, 1000,
|
|
|
|
"On non-zero, enables fault injection on read");
|
2020-04-16 20:10:53 +02:00
|
|
|
|
2020-07-14 21:10:56 +02:00
|
|
|
DEFINE_int32(get_property_one_in, 1000,
|
|
|
|
"If non-zero, then DB::GetProperty() will be called to get various"
|
|
|
|
" properties for every N ops on average. 0 indicates that"
|
|
|
|
" GetProperty() will be not be called.");
|
|
|
|
|
2020-04-16 20:10:53 +02:00
|
|
|
DEFINE_bool(sync_fault_injection, false,
|
|
|
|
"If true, FaultInjectionTestFS will be used for write operations, "
|
|
|
|
" and unsynced data in DB will lost after crash.");
|
2020-06-13 04:24:11 +02:00
|
|
|
|
|
|
|
DEFINE_bool(best_efforts_recovery, false,
|
|
|
|
"If true, use best efforts recovery.");
|
|
|
|
DEFINE_bool(skip_verifydb, false, "If true, skip VerifyDb() calls.");
|
2020-06-18 18:51:14 +02:00
|
|
|
|
|
|
|
DEFINE_bool(enable_compaction_filter, false,
|
|
|
|
"If true, configures a compaction filter that returns a kRemove "
|
|
|
|
"decision for deleted keys.");
|
|
|
|
|
2020-09-30 23:39:47 +02:00
|
|
|
DEFINE_bool(paranoid_file_checks, true,
|
|
|
|
"After writing every SST file, reopen it and read all the keys "
|
|
|
|
"and validate checksums");
|
|
|
|
|
2021-05-05 21:53:42 +02:00
|
|
|
DEFINE_bool(fail_if_options_file_error, false,
|
|
|
|
"Fail operations that fail to detect or properly persist options "
|
|
|
|
"file.");
|
|
|
|
|
Integrity protection for live updates to WriteBatch (#7748)
Summary:
This PR adds the foundation classes for key-value integrity protection and the first use case: protecting live updates from the source buffers added to `WriteBatch` through the destination buffer in `MemTable`. The width of the protection info is not yet configurable -- only eight bytes per key is supported. This PR allows users to enable protection by constructing `WriteBatch` with `protection_bytes_per_key == 8`. It does not yet expose a way for users to get integrity protection via other write APIs (e.g., `Put()`, `Merge()`, `Delete()`, etc.).
The foundation classes (`ProtectionInfo.*`) embed the coverage info in their type, and provide `Protect.*()` and `Strip.*()` functions to navigate between types with different coverage. For making bytes per key configurable (for powers of two up to eight) in the future, these classes are templated on the unsigned integer type used to store the protection info. That integer contains the XOR'd result of hashes with independent seeds for all covered fields. For integer fields, the hash is computed on the raw unadjusted bytes, so the result is endian-dependent. The most significant bytes are truncated when the hash value (8 bytes) is wider than the protection integer.
When `WriteBatch` is constructed with `protection_bytes_per_key == 8`, we hold a `ProtectionInfoKVOTC` (i.e., one that covers key, value, optype aka `ValueType`, timestamp, and CF ID) for each entry added to the batch. The protection info is generated from the original buffers passed by the user, as well as the original metadata generated internally. When writing to memtable, each entry is transformed to a `ProtectionInfoKVOTS` (i.e., dropping coverage of CF ID and adding coverage of sequence number), since at that point we know the sequence number, and have already selected a memtable corresponding to a particular CF. This protection info is verified once the entry is encoded in the `MemTable` buffer.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7748
Test Plan:
- an integration test to verify a wide variety of single-byte changes to the encoded `MemTable` buffer are caught
- add to stress/crash test to verify it works in variety of configs/operations without intentional corruption
- [deferred] unit tests for `ProtectionInfo.*` classes for edge cases like KV swap, `SliceParts` and `Slice` APIs are interchangeable, etc.
Reviewed By: pdillinger
Differential Revision: D25754492
Pulled By: ajkr
fbshipit-source-id: e481bac6c03c2ab268be41359730f1ceb9964866
2021-01-29 21:17:17 +01:00
|
|
|
DEFINE_uint64(batch_protection_bytes_per_key, 0,
|
|
|
|
"If nonzero, enables integrity protection in `WriteBatch` at the "
|
|
|
|
"specified number of bytes per key. Currently the only supported "
|
|
|
|
"nonzero value is eight.");
|
|
|
|
|
2020-09-04 08:49:27 +02:00
|
|
|
DEFINE_string(file_checksum_impl, "none",
|
|
|
|
"Name of an implementation for file_checksum_gen_factory, or "
|
|
|
|
"\"none\" for null.");
|
|
|
|
|
2020-12-17 20:51:04 +01:00
|
|
|
DEFINE_int32(write_fault_one_in, 0,
|
|
|
|
"On non-zero, enables fault injection on write");
|
|
|
|
|
Add user-defined timestamps to db_stress (#8061)
Summary:
Add some basic test for user-defined timestamp to db_stress. Currently,
read with timestamp always tries to read using the current timestamp.
Due to the per-key timestamp-sequence ordering constraint, we only add timestamp-
related tests to the `NonBatchedOpsStressTest` since this test serializes accesses
to the same key and uses a file to cross-check data correctness.
The timestamp feature is not supported in a number of components, e.g. Merge, SingleDelete,
DeleteRange, CompactionFilter, Readonly instance, secondary instance, SST file ingestion, transaction,
etc. Therefore, db_stress should exit if user enables both timestamp and these features at the same
time. The (currently) incompatible features can be found in
`CheckAndSetOptionsForUserTimestamp`.
This PR also fixes a bug triggered when timestamp is enabled together with
`index_type=kBinarySearchWithFirstKey`. This bug fix will also be in another separate PR
with more unit tests coverage. Fixing it here because I do not want to exclude the index type
from crash test.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8061
Test Plan: make crash_test_with_ts
Reviewed By: jay-zhuang
Differential Revision: D27056282
Pulled By: riversand963
fbshipit-source-id: c3e00ad1023fdb9ebbdf9601ec18270c5e2925a9
2021-03-23 13:12:04 +01:00
|
|
|
DEFINE_uint64(user_timestamp_size, 0,
|
|
|
|
"Number of bytes for a user-defined timestamp. Currently, only "
|
|
|
|
"8-byte is supported");
|
|
|
|
|
2021-04-28 19:57:11 +02:00
|
|
|
DEFINE_int32(open_metadata_write_fault_one_in, 0,
|
|
|
|
"On non-zero, enables fault injection on file metadata write "
|
|
|
|
"during DB reopen.");
|
|
|
|
|
2021-06-28 08:53:47 +02:00
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
DEFINE_string(secondary_cache_uri, "",
|
|
|
|
"Full URI for creating a customized secondary cache object");
|
2021-11-08 19:26:48 +01:00
|
|
|
DEFINE_int32(secondary_cache_fault_one_in, 0,
|
|
|
|
"On non-zero, enables fault injection in secondary cache inserts"
|
|
|
|
" and lookups");
|
2021-06-28 08:53:47 +02:00
|
|
|
#endif // ROCKSDB_LITE
|
2021-07-01 01:45:44 +02:00
|
|
|
DEFINE_int32(open_write_fault_one_in, 0,
|
2021-07-06 20:04:04 +02:00
|
|
|
"On non-zero, enables fault injection on file writes "
|
|
|
|
"during DB reopen.");
|
|
|
|
DEFINE_int32(open_read_fault_one_in, 0,
|
|
|
|
"On non-zero, enables fault injection on file reads "
|
2021-07-01 01:45:44 +02:00
|
|
|
"during DB reopen.");
|
2021-07-01 23:15:49 +02:00
|
|
|
DEFINE_int32(injest_error_severity, 1,
|
|
|
|
"The severity of the injested IO Error. 1 is soft error (e.g. "
|
|
|
|
"retryable error), 2 is fatal error, and the default is "
|
|
|
|
"retryable error.");
|
2021-06-28 08:53:47 +02:00
|
|
|
|
2019-12-09 08:49:32 +01:00
|
|
|
#endif // GFLAGS
|