2016-09-23 23:34:04 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2016-09-23 23:34:04 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "rocksdb/options.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
struct ImmutableDBOptions {
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
std::string wal_dir;
|
|
|
|
uint32_t max_subcompactions;
|
|
|
|
int max_background_flushes;
|
|
|
|
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;
|
|
|
|
uint64_t wal_ttl_seconds;
|
|
|
|
uint64_t wal_size_limit_mb;
|
|
|
|
size_t manifest_preallocation_size;
|
|
|
|
bool allow_mmap_reads;
|
|
|
|
bool allow_mmap_writes;
|
2016-10-28 17:36:05 +00:00
|
|
|
bool use_direct_reads;
|
2017-04-13 20:07:33 +00:00
|
|
|
bool use_direct_io_for_flush_and_compaction;
|
2016-09-23 23:34:04 +00:00
|
|
|
bool allow_fallocate;
|
|
|
|
bool is_fd_close_on_exec;
|
|
|
|
bool advise_random_on_open;
|
|
|
|
size_t db_write_buffer_size;
|
|
|
|
std::shared_ptr<WriteBufferManager> write_buffer_manager;
|
|
|
|
DBOptions::AccessHint access_hint_on_compaction_start;
|
|
|
|
bool new_table_reader_for_compaction_inputs;
|
|
|
|
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 21:24:23 +00:00
|
|
|
bool enable_pipelined_write;
|
2016-09-23 23:34:04 +00: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;
|
|
|
|
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 18:32:26 +00:00
|
|
|
bool 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 01:43:29 +00:00
|
|
|
bool preserve_deletes;
|
2017-11-11 01:18:01 +00:00
|
|
|
bool two_write_queues;
|
2017-06-24 21:06:43 +00:00
|
|
|
bool manual_wal_flush;
|
2016-09-23 23:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MutableDBOptions {
|
2016-10-14 19:25:39 +00:00
|
|
|
MutableDBOptions();
|
2016-09-23 23:34:04 +00:00
|
|
|
explicit MutableDBOptions(const MutableDBOptions& options) = default;
|
|
|
|
explicit MutableDBOptions(const DBOptions& options);
|
|
|
|
|
|
|
|
void Dump(Logger* log) const;
|
2016-10-14 19:25:39 +00:00
|
|
|
|
2017-05-24 18:25:38 +00:00
|
|
|
int max_background_jobs;
|
2016-10-14 19:25:39 +00:00
|
|
|
int base_background_compactions;
|
|
|
|
int max_background_compactions;
|
2016-11-02 22:22:13 +00:00
|
|
|
bool avoid_flush_during_shutdown;
|
2017-10-31 20:49:25 +00:00
|
|
|
size_t writable_file_max_buffer_size;
|
2016-11-12 23:43:33 +00:00
|
|
|
uint64_t delayed_write_rate;
|
2016-11-15 06:45:16 +00:00
|
|
|
uint64_t max_total_wal_size;
|
2016-12-05 22:09:35 +00:00
|
|
|
uint64_t delete_obsolete_files_period_micros;
|
2017-03-21 05:50:56 +00:00
|
|
|
unsigned int stats_dump_period_sec;
|
2017-05-04 03:46:17 +00:00
|
|
|
int max_open_files;
|
2017-09-28 00:37:08 +00:00
|
|
|
uint64_t bytes_per_sync;
|
|
|
|
uint64_t wal_bytes_per_sync;
|
2017-11-17 01:46:43 +00:00
|
|
|
size_t compaction_readahead_size;
|
2016-09-23 23:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace rocksdb
|