2016-09-24 01:34:04 +02: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).
|
2016-09-24 01:34:04 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "rocksdb/options.h"
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2021-03-15 12:32:24 +01:00
|
|
|
class SystemClock;
|
2016-09-24 01:34:04 +02:00
|
|
|
|
|
|
|
struct ImmutableDBOptions {
|
2020-09-15 01:59:00 +02:00
|
|
|
static const char* kName() { return "ImmutableDBOptions"; }
|
2016-09-24 01:34:04 +02:00
|
|
|
ImmutableDBOptions();
|
|
|
|
explicit ImmutableDBOptions(const DBOptions& options);
|
|
|
|
|
|
|
|
void Dump(Logger* log) const;
|
|
|
|
|
|
|
|
bool create_if_missing;
|
|
|
|
bool create_missing_column_families;
|
|
|
|
bool error_if_exists;
|
|
|
|
bool paranoid_checks;
|
2021-05-21 01:06:12 +02:00
|
|
|
bool flush_verify_memtable_count;
|
2020-10-10 01:40:25 +02:00
|
|
|
bool track_and_verify_wals_in_manifest;
|
2016-09-24 01:34:04 +02:00
|
|
|
Env* env;
|
|
|
|
std::shared_ptr<RateLimiter> rate_limiter;
|
|
|
|
std::shared_ptr<SstFileManager> sst_file_manager;
|
|
|
|
std::shared_ptr<Logger> info_log;
|
|
|
|
InfoLogLevel info_log_level;
|
|
|
|
int max_file_opening_threads;
|
|
|
|
std::shared_ptr<Statistics> statistics;
|
|
|
|
bool use_fsync;
|
|
|
|
std::vector<DbPath> db_paths;
|
|
|
|
std::string db_log_dir;
|
2021-07-30 21:15:04 +02:00
|
|
|
// The wal_dir option from the file. To determine the
|
|
|
|
// directory in use, the GetWalDir or IsWalDirSameAsDBPath
|
|
|
|
// methods should be used instead of accessing this variable directly.
|
2016-09-24 01:34:04 +02:00
|
|
|
std::string wal_dir;
|
|
|
|
size_t max_log_file_size;
|
|
|
|
size_t log_file_time_to_roll;
|
|
|
|
size_t keep_log_file_num;
|
|
|
|
size_t recycle_log_file_num;
|
|
|
|
uint64_t max_manifest_file_size;
|
|
|
|
int table_cache_numshardbits;
|
2021-04-23 05:42:50 +02:00
|
|
|
uint64_t WAL_ttl_seconds;
|
|
|
|
uint64_t WAL_size_limit_MB;
|
2019-09-12 03:26:22 +02:00
|
|
|
uint64_t max_write_batch_group_size_bytes;
|
2016-09-24 01:34:04 +02:00
|
|
|
size_t manifest_preallocation_size;
|
|
|
|
bool allow_mmap_reads;
|
|
|
|
bool allow_mmap_writes;
|
2016-10-28 19:36:05 +02:00
|
|
|
bool use_direct_reads;
|
2017-04-13 22:07:33 +02:00
|
|
|
bool use_direct_io_for_flush_and_compaction;
|
2016-09-24 01:34:04 +02:00
|
|
|
bool allow_fallocate;
|
|
|
|
bool is_fd_close_on_exec;
|
|
|
|
bool advise_random_on_open;
|
2021-08-11 03:07:48 +02:00
|
|
|
double experimental_mempurge_threshold;
|
2016-09-24 01:34:04 +02:00
|
|
|
size_t db_write_buffer_size;
|
|
|
|
std::shared_ptr<WriteBufferManager> write_buffer_manager;
|
|
|
|
DBOptions::AccessHint access_hint_on_compaction_start;
|
|
|
|
size_t random_access_max_buffer_size;
|
|
|
|
bool use_adaptive_mutex;
|
|
|
|
std::vector<std::shared_ptr<EventListener>> listeners;
|
|
|
|
bool enable_thread_tracking;
|
2017-05-19 23:24:23 +02:00
|
|
|
bool enable_pipelined_write;
|
2019-05-14 02:43:47 +02:00
|
|
|
bool unordered_write;
|
2016-09-24 01:34:04 +02:00
|
|
|
bool allow_concurrent_memtable_write;
|
|
|
|
bool enable_write_thread_adaptive_yield;
|
|
|
|
uint64_t write_thread_max_yield_usec;
|
|
|
|
uint64_t write_thread_slow_yield_usec;
|
|
|
|
bool skip_stats_update_on_db_open;
|
Add an option to prevent DB::Open() from querying sizes of all sst files (#6353)
Summary:
When paranoid_checks is on, DBImpl::CheckConsistency() iterates over all sst files and calls Env::GetFileSize() for each of them. As far as I could understand, this is pretty arbitrary and doesn't affect correctness - if filesystem doesn't corrupt fsynced files, the file sizes will always match; if it does, it may as well corrupt contents as well as sizes, and rocksdb doesn't check contents on open.
If there are thousands of sst files, getting all their sizes takes a while. If, on top of that, Env is overridden to use some remote storage instead of local filesystem, it can be *really* slow and overload the remote storage service. This PR adds an option to not do GetFileSize(); instead it does GetChildren() for parent directory to check that all the expected sst files are at least present, but doesn't check their sizes.
We can't just disable paranoid_checks instead because paranoid_checks do a few other important things: make the DB read-only on write errors, print error messages on read errors, etc.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6353
Test Plan: ran the added sanity check unit test. Will try it out in a LogDevice test cluster where the GetFileSize() calls are causing a lot of trouble.
Differential Revision: D19656425
Pulled By: al13n321
fbshipit-source-id: c2c421b367633033760d1f56747bad206d1fbf82
2020-02-04 10:24:29 +01:00
|
|
|
bool skip_checking_sst_file_sizes_on_db_open;
|
2016-09-24 01:34:04 +02:00
|
|
|
WALRecoveryMode wal_recovery_mode;
|
|
|
|
bool allow_2pc;
|
|
|
|
std::shared_ptr<Cache> row_cache;
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
WalFilter* wal_filter;
|
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
bool fail_if_options_file_error;
|
|
|
|
bool dump_malloc_stats;
|
|
|
|
bool avoid_flush_during_recovery;
|
2017-05-17 20:32:26 +02:00
|
|
|
bool allow_ingest_behind;
|
2017-11-11 02:18:01 +01:00
|
|
|
bool two_write_queues;
|
2017-06-24 23:06:43 +02:00
|
|
|
bool manual_wal_flush;
|
2022-01-26 22:57:30 +01:00
|
|
|
CompressionType wal_compression;
|
2018-10-27 00:06:44 +02:00
|
|
|
bool atomic_flush;
|
2019-04-02 02:07:38 +02:00
|
|
|
bool avoid_unnecessary_blocking_io;
|
2019-06-18 00:17:43 +02:00
|
|
|
bool persist_stats_to_disk;
|
2019-09-03 17:50:47 +02:00
|
|
|
bool write_dbid_to_manifest;
|
2019-07-19 20:54:38 +02:00
|
|
|
size_t log_readahead_size;
|
2020-03-30 00:57:02 +02:00
|
|
|
std::shared_ptr<FileChecksumGenFactory> file_checksum_gen_factory;
|
2020-03-21 03:17:54 +01:00
|
|
|
bool best_efforts_recovery;
|
2020-07-15 20:02:44 +02:00
|
|
|
int max_bgerror_resume_count;
|
|
|
|
uint64_t bgerror_resume_retry_interval;
|
2020-09-30 08:16:12 +02:00
|
|
|
bool allow_data_in_errors;
|
2020-10-19 20:37:05 +02:00
|
|
|
std::string db_host_id;
|
2021-02-11 07:18:33 +01:00
|
|
|
FileTypeSet checksum_handoff_file_types;
|
2021-10-20 00:53:16 +02:00
|
|
|
CacheTier lowest_used_cache_tier;
|
2021-04-23 05:42:50 +02:00
|
|
|
// Convenience/Helper objects that are not part of the base DBOptions
|
|
|
|
std::shared_ptr<FileSystem> fs;
|
|
|
|
SystemClock* clock;
|
2021-04-26 21:43:02 +02:00
|
|
|
Statistics* stats;
|
|
|
|
Logger* logger;
|
2021-05-20 06:40:43 +02:00
|
|
|
std::shared_ptr<CompactionService> compaction_service;
|
2021-07-30 21:15:04 +02:00
|
|
|
|
|
|
|
bool IsWalDirSameAsDBPath() const;
|
|
|
|
bool IsWalDirSameAsDBPath(const std::string& path) const;
|
|
|
|
const std::string& GetWalDir() const;
|
|
|
|
const std::string& GetWalDir(const std::string& path) const;
|
2016-09-24 01:34:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MutableDBOptions {
|
2020-09-15 01:59:00 +02:00
|
|
|
static const char* kName() { return "MutableDBOptions"; }
|
2016-10-14 21:25:39 +02:00
|
|
|
MutableDBOptions();
|
2016-09-24 01:34:04 +02:00
|
|
|
explicit MutableDBOptions(const DBOptions& options);
|
|
|
|
|
|
|
|
void Dump(Logger* log) const;
|
2016-10-14 21:25:39 +02:00
|
|
|
|
2017-05-24 20:25:38 +02:00
|
|
|
int max_background_jobs;
|
2016-10-14 21:25:39 +02:00
|
|
|
int max_background_compactions;
|
2020-07-23 03:31:25 +02:00
|
|
|
uint32_t max_subcompactions;
|
2016-11-02 23:22:13 +01:00
|
|
|
bool avoid_flush_during_shutdown;
|
2017-10-31 21:49:25 +01:00
|
|
|
size_t writable_file_max_buffer_size;
|
2016-11-13 00:43:33 +01:00
|
|
|
uint64_t delayed_write_rate;
|
2016-11-15 07:45:16 +01:00
|
|
|
uint64_t max_total_wal_size;
|
2016-12-05 23:09:35 +01:00
|
|
|
uint64_t delete_obsolete_files_period_micros;
|
2017-03-21 06:50:56 +01:00
|
|
|
unsigned int stats_dump_period_sec;
|
2019-02-21 00:46:59 +01:00
|
|
|
unsigned int stats_persist_period_sec;
|
|
|
|
size_t stats_history_buffer_size;
|
2017-05-04 05:46:17 +02:00
|
|
|
int max_open_files;
|
2017-09-28 02:37:08 +02:00
|
|
|
uint64_t bytes_per_sync;
|
|
|
|
uint64_t wal_bytes_per_sync;
|
Optionally wait on bytes_per_sync to smooth I/O (#5183)
Summary:
The existing implementation does not guarantee bytes reach disk every `bytes_per_sync` when writing SST files, or every `wal_bytes_per_sync` when writing WALs. This can cause confusing behavior for users who enable this feature to avoid large syncs during flush and compaction, but then end up hitting them anyways.
My understanding of the existing behavior is we used `sync_file_range` with `SYNC_FILE_RANGE_WRITE` to submit ranges for async writeback, such that we could continue processing the next range of bytes while that I/O is happening. I believe we can preserve that benefit while also limiting how far the processing can get ahead of the I/O, which prevents huge syncs from happening when the file finishes.
Consider this `sync_file_range` usage: `sync_file_range(fd_, 0, static_cast<off_t>(offset + nbytes), SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE)`. Expanding the range to start at 0 and adding the `SYNC_FILE_RANGE_WAIT_BEFORE` flag causes any pending writeback (like from a previous call to `sync_file_range`) to finish before it proceeds to submit the latest `nbytes` for writeback. The latest `nbytes` are still written back asynchronously, unless processing exceeds I/O speed, in which case the following `sync_file_range` will need to wait on it.
There is a second change in this PR to use `fdatasync` when `sync_file_range` is unavailable (determined statically) or has some known problem with the underlying filesystem (determined dynamically).
The above two changes only apply when the user enables a new option, `strict_bytes_per_sync`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5183
Differential Revision: D14953553
Pulled By: siying
fbshipit-source-id: 445c3862e019fb7b470f9c7f314fc231b62706e9
2019-04-22 20:48:45 +02:00
|
|
|
bool strict_bytes_per_sync;
|
2017-11-17 02:46:43 +01:00
|
|
|
size_t compaction_readahead_size;
|
2020-04-21 01:17:25 +02:00
|
|
|
int max_background_flushes;
|
2016-09-24 01:34:04 +02:00
|
|
|
};
|
|
|
|
|
2021-05-12 01:14:33 +02:00
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
Status GetStringFromMutableDBOptions(const ConfigOptions& config_options,
|
|
|
|
const MutableDBOptions& mutable_opts,
|
|
|
|
std::string* opt_string);
|
|
|
|
|
|
|
|
Status GetMutableDBOptionsFromStrings(
|
|
|
|
const MutableDBOptions& base_options,
|
|
|
|
const std::unordered_map<std::string, std::string>& options_map,
|
|
|
|
MutableDBOptions* new_options);
|
2021-07-21 22:44:39 +02:00
|
|
|
|
|
|
|
bool MutableDBOptionsAreEqual(const MutableDBOptions& this_options,
|
|
|
|
const MutableDBOptions& that_options);
|
2021-05-12 01:14:33 +02:00
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|