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).
|
2013-10-16 23:59:46 +02:00
|
|
|
//
|
2011-03-18 23:37:00 +01:00
|
|
|
// 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.
|
|
|
|
//
|
2015-04-10 01:11:15 +02:00
|
|
|
// Repairer does best effort recovery to recover as much data as possible after
|
|
|
|
// a disaster without compromising consistency. It does not guarantee bringing
|
|
|
|
// the database to a time consistent state.
|
|
|
|
//
|
|
|
|
// Repair process is broken into 4 phases:
|
|
|
|
// (a) Find files
|
|
|
|
// (b) Convert logs to tables
|
|
|
|
// (c) Extract metadata
|
|
|
|
// (d) Write Descriptor
|
|
|
|
//
|
|
|
|
// (a) Find files
|
|
|
|
//
|
|
|
|
// The repairer goes through all the files in the directory, and classifies them
|
|
|
|
// based on their file name. Any file that cannot be identified by name will be
|
|
|
|
// ignored.
|
|
|
|
//
|
|
|
|
// (b) Convert logs to table
|
|
|
|
//
|
|
|
|
// Every log file that is active is replayed. All sections of the file where the
|
|
|
|
// checksum does not match is skipped over. We intentionally give preference to
|
|
|
|
// data consistency.
|
|
|
|
//
|
|
|
|
// (c) Extract metadata
|
|
|
|
//
|
|
|
|
// We scan every table to compute
|
|
|
|
// (1) smallest/largest for the table
|
|
|
|
// (2) largest sequence number in the table
|
2019-10-15 00:19:31 +02:00
|
|
|
// (3) oldest blob file referred to by the table (if applicable)
|
2015-04-10 01:11:15 +02:00
|
|
|
//
|
|
|
|
// If we are unable to scan the file, then we ignore the table.
|
|
|
|
//
|
|
|
|
// (d) Write Descriptor
|
|
|
|
//
|
|
|
|
// We generate descriptor contents:
|
|
|
|
// - log number is set to zero
|
|
|
|
// - next-file-number is set to 1 + largest file number we found
|
|
|
|
// - last-sequence-number is set to largest sequence# found across
|
|
|
|
// all tables (see 2c)
|
|
|
|
// - compaction pointers are cleared
|
|
|
|
// - every table file is added at level 0
|
2011-03-18 23:37:00 +01:00
|
|
|
//
|
|
|
|
// Possible optimization 1:
|
|
|
|
// (a) Compute total size and use to pick appropriate max-level M
|
|
|
|
// (b) Sort tables by largest sequence# in the table
|
|
|
|
// (c) For each table: if it overlaps earlier table, place in level-0,
|
|
|
|
// else place in level-M.
|
2015-04-10 01:11:15 +02:00
|
|
|
// (d) We can provide options for time consistent recovery and unsafe recovery
|
|
|
|
// (ignore checksum failure when applicable)
|
2011-03-18 23:37:00 +01:00
|
|
|
// Possible optimization 2:
|
2011-04-21 00:48:11 +02:00
|
|
|
// Store per-table metadata (smallest, largest, largest-seq#, ...)
|
|
|
|
// in the table's meta section to speed up ScanTable.
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2014-04-15 22:39:26 +02:00
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
|
2019-06-06 22:52:39 +02:00
|
|
|
#include <cinttypes>
|
2011-03-18 23:37:00 +01:00
|
|
|
#include "db/builder.h"
|
2019-05-31 20:52:59 +02:00
|
|
|
#include "db/db_impl/db_impl.h"
|
2011-03-18 23:37:00 +01:00
|
|
|
#include "db/dbformat.h"
|
|
|
|
#include "db/log_reader.h"
|
|
|
|
#include "db/log_writer.h"
|
|
|
|
#include "db/memtable.h"
|
|
|
|
#include "db/table_cache.h"
|
|
|
|
#include "db/version_edit.h"
|
|
|
|
#include "db/write_batch_internal.h"
|
2019-05-30 05:44:08 +02:00
|
|
|
#include "file/filename.h"
|
2019-09-16 19:31:27 +02:00
|
|
|
#include "file/writable_file_writer.h"
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "options/cf_options.h"
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/comparator.h"
|
|
|
|
#include "rocksdb/db.h"
|
|
|
|
#include "rocksdb/env.h"
|
2016-06-25 01:29:43 +02:00
|
|
|
#include "rocksdb/options.h"
|
2016-06-21 03:01:03 +02:00
|
|
|
#include "rocksdb/write_buffer_manager.h"
|
2015-10-13 00:06:38 +02:00
|
|
|
#include "table/scoped_arena_iterator.h"
|
2016-06-25 01:29:43 +02:00
|
|
|
#include "util/string_util.h"
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class Repairer {
|
|
|
|
public:
|
2016-06-25 01:29:43 +02:00
|
|
|
Repairer(const std::string& dbname, const DBOptions& db_options,
|
|
|
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
|
|
|
const ColumnFamilyOptions& default_cf_opts,
|
|
|
|
const ColumnFamilyOptions& unknown_cf_opts, bool create_unknown_cfs)
|
2011-03-18 23:37:00 +01:00
|
|
|
: dbname_(dbname),
|
2021-08-18 20:32:00 +02:00
|
|
|
db_session_id_(DBImpl::GenerateDbSessionId(db_options.env)),
|
2016-06-25 01:29:43 +02:00
|
|
|
env_(db_options.env),
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
file_options_(),
|
2016-06-25 01:29:43 +02:00
|
|
|
db_options_(SanitizeOptions(dbname_, db_options)),
|
2017-09-28 02:37:08 +02:00
|
|
|
immutable_db_options_(ImmutableDBOptions(db_options_)),
|
2016-06-25 01:29:43 +02:00
|
|
|
icmp_(default_cf_opts.comparator),
|
2018-04-06 04:49:06 +02:00
|
|
|
default_cf_opts_(
|
|
|
|
SanitizeOptions(immutable_db_options_, default_cf_opts)),
|
2021-05-05 22:59:21 +02:00
|
|
|
default_iopts_(
|
|
|
|
ImmutableOptions(immutable_db_options_, default_cf_opts_)),
|
2018-04-06 04:49:06 +02:00
|
|
|
unknown_cf_opts_(
|
|
|
|
SanitizeOptions(immutable_db_options_, unknown_cf_opts)),
|
2016-06-25 01:29:43 +02:00
|
|
|
create_unknown_cfs_(create_unknown_cfs),
|
[CF] Rethink table cache
Summary:
Adapting table cache to column families is interesting. We want table cache to be global LRU, so if some column families are use not as often as others, we want them to be evicted from cache. However, current TableCache object also constructs tables on its own. If table is not found in the cache, TableCache automatically creates new table. We want each column family to be able to specify different table factory.
To solve the problem, we still have a single LRU, but we provide the LRUCache object to TableCache on construction. We have one TableCache per column family, but the underyling cache is shared by all TableCache objects.
This allows us to have a global LRU, but still be able to support different table factories for different column families. Also, in the future it will also be able to support different directories for different column families.
Test Plan: make check
Reviewers: dhruba, haobo, kailiu, sdong
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15915
2014-02-05 18:07:55 +01:00
|
|
|
raw_table_cache_(
|
|
|
|
// TableCache can be small since we expect each table to be opened
|
|
|
|
// once.
|
2016-06-25 01:29:43 +02:00
|
|
|
NewLRUCache(10, db_options_.table_cache_numshardbits)),
|
2021-08-18 20:32:00 +02:00
|
|
|
table_cache_(new TableCache(default_iopts_, &file_options_,
|
|
|
|
raw_table_cache_.get(),
|
|
|
|
/*block_cache_tracer=*/nullptr,
|
|
|
|
/*io_tracer=*/nullptr, db_session_id_)),
|
2016-06-25 01:29:43 +02:00
|
|
|
wb_(db_options_.db_write_buffer_size),
|
|
|
|
wc_(db_options_.delayed_write_rate),
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
vset_(dbname_, &immutable_db_options_, file_options_,
|
2019-06-14 00:39:52 +02:00
|
|
|
raw_table_cache_.get(), &wb_, &wc_,
|
2021-06-10 20:01:44 +02:00
|
|
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
2021-08-18 20:32:00 +02:00
|
|
|
db_session_id_),
|
2018-11-29 20:24:33 +01:00
|
|
|
next_file_number_(1),
|
2020-09-30 01:28:42 +02:00
|
|
|
db_lock_(nullptr),
|
|
|
|
closed_(false) {
|
2016-06-25 01:29:43 +02:00
|
|
|
for (const auto& cfd : column_families) {
|
|
|
|
cf_name_to_opts_[cfd.name] = cfd.options;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const ColumnFamilyOptions* GetColumnFamilyOptions(
|
|
|
|
const std::string& cf_name) {
|
|
|
|
if (cf_name_to_opts_.find(cf_name) == cf_name_to_opts_.end()) {
|
|
|
|
if (create_unknown_cfs_) {
|
|
|
|
return &unknown_cf_opts_;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return &cf_name_to_opts_[cf_name];
|
2016-06-24 20:19:40 +02:00
|
|
|
}
|
A new call back to TablePropertiesCollector to allow users know the entry is add, delete or merge
Summary:
Currently users have no idea a key is add, delete or merge from TablePropertiesCollector call back. Add a new function to add it.
Also refactor the codes so that
(1) make table property collector and internal table property collector two separate data structures with the later one now exposed
(2) table builders only receive internal table properties
Test Plan: Add cases in table_properties_collector_test to cover both of old and new ways of using TablePropertiesCollector.
Reviewers: yhchiang, igor.sugak, rven, igor
Reviewed By: rven, igor
Subscribers: meyering, yoshinorim, maykov, leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D35373
2015-04-06 19:04:30 +02:00
|
|
|
|
2016-06-24 20:19:40 +02:00
|
|
|
// Adds a column family to the VersionSet with cf_options_ and updates
|
|
|
|
// manifest.
|
|
|
|
Status AddColumnFamily(const std::string& cf_name, uint32_t cf_id) {
|
2016-06-25 01:29:43 +02:00
|
|
|
const auto* cf_opts = GetColumnFamilyOptions(cf_name);
|
|
|
|
if (cf_opts == nullptr) {
|
|
|
|
return Status::Corruption("Encountered unknown column family with name=" +
|
|
|
|
cf_name + ", id=" + ToString(cf_id));
|
|
|
|
}
|
|
|
|
Options opts(db_options_, *cf_opts);
|
2016-09-14 06:11:59 +02:00
|
|
|
MutableCFOptions mut_cf_opts(opts);
|
2016-06-24 20:19:40 +02:00
|
|
|
|
|
|
|
VersionEdit edit;
|
2016-06-25 01:29:43 +02:00
|
|
|
edit.SetComparatorName(opts.comparator->Name());
|
2016-06-24 20:19:40 +02:00
|
|
|
edit.SetLogNumber(0);
|
|
|
|
edit.SetColumnFamily(cf_id);
|
|
|
|
ColumnFamilyData* cfd;
|
|
|
|
cfd = nullptr;
|
|
|
|
edit.AddColumnFamily(cf_name);
|
|
|
|
|
|
|
|
mutex_.Lock();
|
2016-06-25 01:29:43 +02:00
|
|
|
Status status = vset_.LogAndApply(cfd, mut_cf_opts, &edit, &mutex_,
|
|
|
|
nullptr /* db_directory */,
|
|
|
|
false /* new_descriptor_log */, cf_opts);
|
2016-06-24 20:19:40 +02:00
|
|
|
mutex_.Unlock();
|
|
|
|
return status;
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
|
2020-09-30 01:28:42 +02:00
|
|
|
Status Close() {
|
|
|
|
Status s = Status::OK();
|
|
|
|
if (!closed_) {
|
|
|
|
if (db_lock_ != nullptr) {
|
|
|
|
s = env_->UnlockFile(db_lock_);
|
|
|
|
db_lock_ = nullptr;
|
|
|
|
}
|
|
|
|
closed_ = true;
|
2018-10-12 19:40:06 +02:00
|
|
|
}
|
2020-09-30 01:28:42 +02:00
|
|
|
return s;
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
|
2020-09-30 01:28:42 +02:00
|
|
|
~Repairer() { Close().PermitUncheckedError(); }
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
Status Run() {
|
2018-10-12 19:40:06 +02:00
|
|
|
Status status = env_->LockFile(LockFileName(dbname_), &db_lock_);
|
|
|
|
if (!status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
status = FindFiles();
|
2020-09-30 01:28:42 +02:00
|
|
|
DBImpl* db_impl = nullptr;
|
2016-06-24 20:19:40 +02:00
|
|
|
if (status.ok()) {
|
|
|
|
// Discard older manifests and start a fresh one
|
|
|
|
for (size_t i = 0; i < manifests_.size(); i++) {
|
|
|
|
ArchiveFile(dbname_ + "/" + manifests_[i]);
|
|
|
|
}
|
|
|
|
// Just create a DBImpl temporarily so we can reuse NewDB()
|
2020-09-30 01:28:42 +02:00
|
|
|
db_impl = new DBImpl(db_options_, dbname_);
|
2020-07-10 22:39:47 +02:00
|
|
|
status = db_impl->NewDB(/*new_filenames=*/nullptr);
|
2016-06-24 20:19:40 +02:00
|
|
|
}
|
2020-09-30 01:28:42 +02:00
|
|
|
delete db_impl;
|
2017-08-08 19:42:38 +02:00
|
|
|
|
2016-06-24 20:19:40 +02:00
|
|
|
if (status.ok()) {
|
|
|
|
// Recover using the fresh manifest created by NewDB()
|
2016-06-25 01:29:43 +02:00
|
|
|
status =
|
|
|
|
vset_.Recover({{kDefaultColumnFamilyName, default_cf_opts_}}, false);
|
2016-06-24 20:19:40 +02:00
|
|
|
}
|
2011-03-18 23:37:00 +01:00
|
|
|
if (status.ok()) {
|
2016-06-24 22:12:13 +02:00
|
|
|
// Need to scan existing SST files first so the column families are
|
|
|
|
// created before we process WAL files
|
|
|
|
ExtractMetaData();
|
|
|
|
|
|
|
|
// ExtractMetaData() uses table_fds_ to know which SST files' metadata to
|
|
|
|
// extract -- we need to clear it here since metadata for existing SST
|
|
|
|
// files has been extracted already
|
|
|
|
table_fds_.clear();
|
2011-03-18 23:37:00 +01:00
|
|
|
ConvertLogFilesToTables();
|
|
|
|
ExtractMetaData();
|
2016-06-24 20:19:40 +02:00
|
|
|
status = AddTables();
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
if (status.ok()) {
|
2014-06-28 01:01:59 +02:00
|
|
|
uint64_t bytes = 0;
|
2011-04-21 00:48:11 +02:00
|
|
|
for (size_t i = 0; i < tables_.size(); i++) {
|
2014-06-14 00:54:19 +02:00
|
|
|
bytes += tables_[i].meta.fd.GetFileSize();
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_WARN(db_options_.info_log,
|
|
|
|
"**** Repaired rocksdb %s; "
|
|
|
|
"recovered %" ROCKSDB_PRIszt " files; %" PRIu64
|
2018-05-11 20:14:20 +02:00
|
|
|
" bytes. "
|
2017-03-16 03:22:52 +01:00
|
|
|
"Some data may have been lost. "
|
|
|
|
"****",
|
|
|
|
dbname_.c_str(), tables_.size(), bytes);
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct TableInfo {
|
|
|
|
FileMetaData meta;
|
2016-06-24 22:12:13 +02:00
|
|
|
uint32_t column_family_id;
|
|
|
|
std::string column_family_name;
|
2011-03-18 23:37:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
std::string const dbname_;
|
2020-06-17 19:55:42 +02:00
|
|
|
std::string db_session_id_;
|
2011-03-18 23:37:00 +01:00
|
|
|
Env* const env_;
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
const FileOptions file_options_;
|
2016-06-25 01:29:43 +02:00
|
|
|
const DBOptions db_options_;
|
2016-09-24 01:34:04 +02:00
|
|
|
const ImmutableDBOptions immutable_db_options_;
|
2016-06-25 01:29:43 +02:00
|
|
|
const InternalKeyComparator icmp_;
|
|
|
|
const ColumnFamilyOptions default_cf_opts_;
|
2021-05-05 22:59:21 +02:00
|
|
|
const ImmutableOptions default_iopts_; // table_cache_ holds reference
|
2016-06-25 01:29:43 +02:00
|
|
|
const ColumnFamilyOptions unknown_cf_opts_;
|
|
|
|
const bool create_unknown_cfs_;
|
[CF] Rethink table cache
Summary:
Adapting table cache to column families is interesting. We want table cache to be global LRU, so if some column families are use not as often as others, we want them to be evicted from cache. However, current TableCache object also constructs tables on its own. If table is not found in the cache, TableCache automatically creates new table. We want each column family to be able to specify different table factory.
To solve the problem, we still have a single LRU, but we provide the LRUCache object to TableCache on construction. We have one TableCache per column family, but the underyling cache is shared by all TableCache objects.
This allows us to have a global LRU, but still be able to support different table factories for different column families. Also, in the future it will also be able to support different directories for different column families.
Test Plan: make check
Reviewers: dhruba, haobo, kailiu, sdong
CC: leveldb
Differential Revision: https://reviews.facebook.net/D15915
2014-02-05 18:07:55 +01:00
|
|
|
std::shared_ptr<Cache> raw_table_cache_;
|
2020-09-30 01:28:42 +02:00
|
|
|
std::unique_ptr<TableCache> table_cache_;
|
2016-06-21 03:01:03 +02:00
|
|
|
WriteBufferManager wb_;
|
2016-06-24 20:19:40 +02:00
|
|
|
WriteController wc_;
|
|
|
|
VersionSet vset_;
|
2016-06-25 01:29:43 +02:00
|
|
|
std::unordered_map<std::string, ColumnFamilyOptions> cf_name_to_opts_;
|
2016-06-24 20:19:40 +02:00
|
|
|
InstrumentedMutex mutex_;
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
std::vector<std::string> manifests_;
|
2014-07-02 18:54:20 +02:00
|
|
|
std::vector<FileDescriptor> table_fds_;
|
2011-03-18 23:37:00 +01:00
|
|
|
std::vector<uint64_t> logs_;
|
|
|
|
std::vector<TableInfo> tables_;
|
|
|
|
uint64_t next_file_number_;
|
2018-10-12 19:40:06 +02:00
|
|
|
// Lock over the persistent DB state. Non-nullptr iff successfully
|
|
|
|
// acquired.
|
|
|
|
FileLock* db_lock_;
|
2020-09-30 01:28:42 +02:00
|
|
|
bool closed_;
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
Status FindFiles() {
|
|
|
|
std::vector<std::string> filenames;
|
2014-07-02 18:54:20 +02:00
|
|
|
bool found_file = false;
|
2017-08-08 19:42:38 +02:00
|
|
|
std::vector<std::string> to_search_paths;
|
|
|
|
|
2016-06-25 01:29:43 +02:00
|
|
|
for (size_t path_id = 0; path_id < db_options_.db_paths.size(); path_id++) {
|
2017-08-08 19:42:38 +02:00
|
|
|
to_search_paths.push_back(db_options_.db_paths[path_id].path);
|
|
|
|
}
|
|
|
|
|
|
|
|
// search wal_dir if user uses a customize wal_dir
|
2021-07-30 21:15:04 +02:00
|
|
|
bool same = immutable_db_options_.IsWalDirSameAsDBPath(dbname_);
|
2017-09-22 21:37:59 +02:00
|
|
|
if (!same) {
|
2021-07-30 21:15:04 +02:00
|
|
|
to_search_paths.push_back(immutable_db_options_.wal_dir);
|
2017-08-08 19:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t path_id = 0; path_id < to_search_paths.size(); path_id++) {
|
2021-07-29 01:43:16 +02:00
|
|
|
ROCKS_LOG_INFO(db_options_.info_log, "Searching path %s\n",
|
|
|
|
to_search_paths[path_id].c_str());
|
2021-07-30 21:15:04 +02:00
|
|
|
Status status = env_->GetChildren(to_search_paths[path_id], &filenames);
|
2014-07-02 18:54:20 +02:00
|
|
|
if (!status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if (!filenames.empty()) {
|
|
|
|
found_file = true;
|
|
|
|
}
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2014-07-02 18:54:20 +02:00
|
|
|
uint64_t number;
|
|
|
|
FileType type;
|
|
|
|
for (size_t i = 0; i < filenames.size(); i++) {
|
|
|
|
if (ParseFileName(filenames[i], &number, &type)) {
|
|
|
|
if (type == kDescriptorFile) {
|
|
|
|
manifests_.push_back(filenames[i]);
|
2011-03-18 23:37:00 +01:00
|
|
|
} else {
|
2014-07-02 18:54:20 +02:00
|
|
|
if (number + 1 > next_file_number_) {
|
|
|
|
next_file_number_ = number + 1;
|
|
|
|
}
|
2020-10-23 02:04:39 +02:00
|
|
|
if (type == kWalFile) {
|
2014-07-02 18:54:20 +02:00
|
|
|
logs_.push_back(number);
|
|
|
|
} else if (type == kTableFile) {
|
2015-12-28 23:28:19 +01:00
|
|
|
table_fds_.emplace_back(number, static_cast<uint32_t>(path_id),
|
|
|
|
0);
|
2014-07-02 18:54:20 +02:00
|
|
|
} else {
|
|
|
|
// Ignore other files
|
|
|
|
}
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-02 18:54:20 +02:00
|
|
|
if (!found_file) {
|
|
|
|
return Status::Corruption(dbname_, "repair found no files");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConvertLogFilesToTables() {
|
2021-07-30 21:15:04 +02:00
|
|
|
const auto& wal_dir = immutable_db_options_.GetWalDir();
|
2011-04-21 00:48:11 +02:00
|
|
|
for (size_t i = 0; i < logs_.size(); i++) {
|
2017-08-08 19:42:38 +02:00
|
|
|
// we should use LogFileName(wal_dir, logs_[i]) here. user might uses wal_dir option.
|
2021-07-30 21:15:04 +02:00
|
|
|
std::string logname = LogFileName(wal_dir, logs_[i]);
|
|
|
|
Status status = ConvertLogToTable(wal_dir, logs_[i]);
|
2011-03-18 23:37:00 +01:00
|
|
|
if (!status.ok()) {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_WARN(db_options_.info_log,
|
|
|
|
"Log #%" PRIu64 ": ignoring conversion error: %s",
|
|
|
|
logs_[i], status.ToString().c_str());
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
ArchiveFile(logname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-30 21:15:04 +02:00
|
|
|
Status ConvertLogToTable(const std::string& wal_dir, uint64_t log) {
|
2011-03-18 23:37:00 +01:00
|
|
|
struct LogReporter : public log::Reader::Reporter {
|
|
|
|
Env* env;
|
2013-01-20 11:07:13 +01:00
|
|
|
std::shared_ptr<Logger> info_log;
|
2011-03-18 23:37:00 +01:00
|
|
|
uint64_t lognum;
|
2019-02-14 22:52:47 +01:00
|
|
|
void Corruption(size_t bytes, const Status& s) override {
|
2011-03-18 23:37:00 +01:00
|
|
|
// We print error messages for corruption, but continue repairing.
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_ERROR(info_log, "Log #%" PRIu64 ": dropping %d bytes; %s",
|
|
|
|
lognum, static_cast<int>(bytes), s.ToString().c_str());
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Open the log file
|
2021-07-30 21:15:04 +02:00
|
|
|
std::string logname = LogFileName(wal_dir, log);
|
2021-01-29 07:08:46 +01:00
|
|
|
const auto& fs = env_->GetFileSystem();
|
|
|
|
std::unique_ptr<SequentialFileReader> lfile_reader;
|
|
|
|
Status status = SequentialFileReader::Create(
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
fs, logname, fs->OptimizeForLogRead(file_options_), &lfile_reader,
|
2021-01-29 07:08:46 +01:00
|
|
|
nullptr);
|
2011-03-18 23:37:00 +01:00
|
|
|
if (!status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the log reader.
|
|
|
|
LogReporter reporter;
|
|
|
|
reporter.env = env_;
|
2016-06-25 01:29:43 +02:00
|
|
|
reporter.info_log = db_options_.info_log;
|
2011-03-18 23:37:00 +01:00
|
|
|
reporter.lognum = log;
|
2016-06-24 20:19:40 +02:00
|
|
|
// We intentionally make log::Reader do checksumming so that
|
2011-03-18 23:37:00 +01:00
|
|
|
// corruptions cause entire commits to be skipped instead of
|
|
|
|
// propagating bad information (like overly large sequence
|
|
|
|
// numbers).
|
2016-06-25 01:29:43 +02:00
|
|
|
log::Reader reader(db_options_.info_log, std::move(lfile_reader), &reporter,
|
2019-03-27 00:41:31 +01:00
|
|
|
true /*enable checksum*/, log);
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2016-06-24 22:12:13 +02:00
|
|
|
// Initialize per-column family memtables
|
|
|
|
for (auto* cfd : *vset_.GetColumnFamilySet()) {
|
|
|
|
cfd->CreateNewMemtable(*cfd->GetLatestMutableCFOptions(),
|
2021-07-23 03:26:47 +02:00
|
|
|
kMaxSequenceNumber);
|
2016-06-24 22:12:13 +02:00
|
|
|
}
|
|
|
|
auto cf_mems = new ColumnFamilyMemTablesImpl(vset_.GetColumnFamilySet());
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
// Read all the records and add to a memtable
|
|
|
|
std::string scratch;
|
|
|
|
Slice record;
|
|
|
|
WriteBatch batch;
|
|
|
|
int counter = 0;
|
|
|
|
while (reader.ReadRecord(&record, &scratch)) {
|
2016-03-30 19:35:22 +02:00
|
|
|
if (record.size() < WriteBatchInternal::kHeader) {
|
2011-03-18 23:37:00 +01:00
|
|
|
reporter.Corruption(
|
|
|
|
record.size(), Status::Corruption("log record too small"));
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-30 01:28:42 +02:00
|
|
|
Status record_status = WriteBatchInternal::SetContents(&batch, record);
|
|
|
|
if (record_status.ok()) {
|
|
|
|
record_status =
|
|
|
|
WriteBatchInternal::InsertInto(&batch, cf_mems, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
if (record_status.ok()) {
|
2011-03-18 23:37:00 +01:00
|
|
|
counter += WriteBatchInternal::Count(&batch);
|
|
|
|
} else {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_WARN(db_options_.info_log, "Log #%" PRIu64 ": ignoring %s",
|
2020-09-30 01:28:42 +02:00
|
|
|
log, record_status.ToString().c_str());
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 22:12:13 +02:00
|
|
|
// Dump a table for each column family with entries in this log file.
|
|
|
|
for (auto* cfd : *vset_.GetColumnFamilySet()) {
|
|
|
|
// Do not record a version edit for this conversion to a Table
|
|
|
|
// since ExtractMetaData() will also generate edits.
|
|
|
|
MemTable* mem = cfd->mem();
|
|
|
|
if (mem->IsEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileMetaData meta;
|
|
|
|
meta.fd = FileDescriptor(next_file_number_++, 0, 0);
|
2014-09-05 02:40:41 +02:00
|
|
|
ReadOptions ro;
|
|
|
|
ro.total_order_seek = true;
|
|
|
|
Arena arena;
|
|
|
|
ScopedArenaIterator iter(mem->NewIterator(ro, &arena));
|
2017-07-05 21:02:00 +02:00
|
|
|
int64_t _current_time = 0;
|
2021-03-15 12:32:24 +01:00
|
|
|
immutable_db_options_.clock->GetCurrentTime(&_current_time)
|
|
|
|
.PermitUncheckedError(); // ignore error
|
2017-06-28 02:02:20 +02:00
|
|
|
const uint64_t current_time = static_cast<uint64_t>(_current_time);
|
2017-10-18 18:09:31 +02:00
|
|
|
SnapshotChecker* snapshot_checker = DisableGCSnapshotChecker::Instance();
|
2017-11-10 18:25:26 +01:00
|
|
|
|
|
|
|
auto write_hint = cfd->CalculateSSTWriteHint(0);
|
2018-12-17 22:12:22 +01:00
|
|
|
std::vector<std::unique_ptr<FragmentedRangeTombstoneIterator>>
|
|
|
|
range_del_iters;
|
|
|
|
auto range_del_iter =
|
|
|
|
mem->NewRangeTombstoneIterator(ro, kMaxSequenceNumber);
|
|
|
|
if (range_del_iter != nullptr) {
|
|
|
|
range_del_iters.emplace_back(range_del_iter);
|
|
|
|
}
|
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
|
|
|
|
Pass IOStatus to write path and set retryable IO Error as hard error in BG jobs (#6487)
Summary:
In the current code base, we use Status to get and store the returned status from the call. Specifically, for IO related functions, the current Status cannot reflect the IO Error details such as error scope, error retryable attribute, and others. With the implementation of https://github.com/facebook/rocksdb/issues/5761, we have the new Wrapper for IO, which returns IOStatus instead of Status. However, the IOStatus is purged at the lower level of write path and transferred to Status.
The first job of this PR is to pass the IOStatus to the write path (flush, WAL write, and Compaction). The second job is to identify the Retryable IO Error as HardError, and set the bg_error_ as HardError. In this case, the DB Instance becomes read only. User is informed of the Status and need to take actions to deal with it (e.g., call db->Resume()).
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6487
Test Plan: Added the testing case to error_handler_fs_test. Pass make asan_check
Reviewed By: anand1976
Differential Revision: D20685017
Pulled By: zhichao-cao
fbshipit-source-id: ff85f042896243abcd6ef37877834e26f36b6eb0
2020-03-28 00:03:05 +01:00
|
|
|
IOStatus io_s;
|
2021-04-29 15:59:53 +02:00
|
|
|
CompressionOptions default_compression;
|
|
|
|
TableBuilderOptions tboptions(
|
|
|
|
*cfd->ioptions(), *cfd->GetLatestMutableCFOptions(),
|
|
|
|
cfd->internal_comparator(), cfd->int_tbl_prop_collector_factories(),
|
Add more LSM info to FilterBuildingContext (#8246)
Summary:
Add `num_levels`, `is_bottommost`, and table file creation
`reason` to `FilterBuildingContext`, in anticipation of more powerful
Bloom-like filter support.
To support this, added `is_bottommost` and `reason` to
`TableBuilderOptions`, which allowed removing `reason` parameter from
`rocksdb::BuildTable`.
I attempted to remove `skip_filters` from `TableBuilderOptions`, because
filter construction decisions should arise from options, not one-off
parameters. I could not completely remove it because the public API for
SstFileWriter takes a `skip_filters` parameter, and translating this
into an option change would mean awkwardly replacing the table_factory
if it is BlockBasedTableFactory with new filter_policy=nullptr option.
I marked this public skip_filters option as deprecated because of this
oddity. (skip_filters on the read side probably makes sense.)
At least `skip_filters` is now largely hidden for users of
`TableBuilderOptions` and is no longer used for implementing the
optimize_filters_for_hits option. Bringing the logic for that option
closer to handling of FilterBuildingContext makes it more obvious that
hese two are using the same notion of "bottommost." (Planned:
configuration options for Bloom-like filters that generalize
`optimize_filters_for_hits`)
Recommended follow-up: Try to get away from "bottommost level" naming of
things, which is inaccurate (see
VersionStorageInfo::RangeMightExistAfterSortedRun), and move to
"bottommost run" or just "bottommost."
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8246
Test Plan:
extended an existing unit test to exercise and check various
filter building contexts. Also, existing tests for
optimize_filters_for_hits validate some of the "bottommost" handling,
which is now closely connected to FilterBuildingContext::is_bottommost
through TableBuilderOptions::is_bottommost
Reviewed By: mrambacher
Differential Revision: D28099346
Pulled By: pdillinger
fbshipit-source-id: 2c1072e29c24d4ac404c761a7b7663292372600a
2021-04-30 22:49:24 +02:00
|
|
|
kNoCompression, default_compression, cfd->GetID(), cfd->GetName(),
|
|
|
|
-1 /* level */, false /* is_bottommost */,
|
|
|
|
TableFileCreationReason::kRecovery, current_time,
|
2021-04-29 15:59:53 +02:00
|
|
|
0 /* oldest_key_time */, 0 /* file_creation_time */,
|
2021-06-10 20:01:44 +02:00
|
|
|
"DB Repairer" /* db_id */, db_session_id_, 0 /*target_file_size*/,
|
|
|
|
meta.fd.GetNumber());
|
2015-10-09 01:57:35 +02:00
|
|
|
status = BuildTable(
|
2021-04-29 15:59:53 +02:00
|
|
|
dbname_, /* versions */ nullptr, immutable_db_options_, tboptions,
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
file_options_, table_cache_.get(), iter.get(),
|
2021-04-29 15:59:53 +02:00
|
|
|
std::move(range_del_iters), &meta, nullptr /* blob_file_additions */,
|
|
|
|
{}, kMaxSequenceNumber, snapshot_checker,
|
Add more LSM info to FilterBuildingContext (#8246)
Summary:
Add `num_levels`, `is_bottommost`, and table file creation
`reason` to `FilterBuildingContext`, in anticipation of more powerful
Bloom-like filter support.
To support this, added `is_bottommost` and `reason` to
`TableBuilderOptions`, which allowed removing `reason` parameter from
`rocksdb::BuildTable`.
I attempted to remove `skip_filters` from `TableBuilderOptions`, because
filter construction decisions should arise from options, not one-off
parameters. I could not completely remove it because the public API for
SstFileWriter takes a `skip_filters` parameter, and translating this
into an option change would mean awkwardly replacing the table_factory
if it is BlockBasedTableFactory with new filter_policy=nullptr option.
I marked this public skip_filters option as deprecated because of this
oddity. (skip_filters on the read side probably makes sense.)
At least `skip_filters` is now largely hidden for users of
`TableBuilderOptions` and is no longer used for implementing the
optimize_filters_for_hits option. Bringing the logic for that option
closer to handling of FilterBuildingContext makes it more obvious that
hese two are using the same notion of "bottommost." (Planned:
configuration options for Bloom-like filters that generalize
`optimize_filters_for_hits`)
Recommended follow-up: Try to get away from "bottommost level" naming of
things, which is inaccurate (see
VersionStorageInfo::RangeMightExistAfterSortedRun), and move to
"bottommost run" or just "bottommost."
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8246
Test Plan:
extended an existing unit test to exercise and check various
filter building contexts. Also, existing tests for
optimize_filters_for_hits validate some of the "bottommost" handling,
which is now closely connected to FilterBuildingContext::is_bottommost
through TableBuilderOptions::is_bottommost
Reviewed By: mrambacher
Differential Revision: D28099346
Pulled By: pdillinger
fbshipit-source-id: 2c1072e29c24d4ac404c761a7b7663292372600a
2021-04-30 22:49:24 +02:00
|
|
|
false /* paranoid_file_checks*/, nullptr /* internal_stats */, &io_s,
|
|
|
|
nullptr /*IOTracer*/, nullptr /* event_logger */, 0 /* job_id */,
|
|
|
|
Env::IO_HIGH, nullptr /* table_properties */, write_hint);
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(db_options_.info_log,
|
|
|
|
"Log #%" PRIu64 ": %d ops saved to Table #%" PRIu64 " %s",
|
|
|
|
log, counter, meta.fd.GetNumber(),
|
|
|
|
status.ToString().c_str());
|
2016-06-24 22:12:13 +02:00
|
|
|
if (status.ok()) {
|
|
|
|
if (meta.fd.GetFileSize() > 0) {
|
|
|
|
table_fds_.push_back(meta.fd);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 22:12:13 +02:00
|
|
|
delete cf_mems;
|
2011-03-18 23:37:00 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExtractMetaData() {
|
2014-07-02 18:54:20 +02:00
|
|
|
for (size_t i = 0; i < table_fds_.size(); i++) {
|
2011-03-18 23:37:00 +01:00
|
|
|
TableInfo t;
|
2014-07-02 18:54:20 +02:00
|
|
|
t.meta.fd = table_fds_[i];
|
2011-03-18 23:37:00 +01:00
|
|
|
Status status = ScanTable(&t);
|
|
|
|
if (!status.ok()) {
|
2014-07-02 18:54:20 +02:00
|
|
|
std::string fname = TableFileName(
|
2016-06-25 01:29:43 +02:00
|
|
|
db_options_.db_paths, t.meta.fd.GetNumber(), t.meta.fd.GetPathId());
|
2014-08-13 20:57:40 +02:00
|
|
|
char file_num_buf[kFormatFileNumberBufSize];
|
|
|
|
FormatFileNumber(t.meta.fd.GetNumber(), t.meta.fd.GetPathId(),
|
|
|
|
file_num_buf, sizeof(file_num_buf));
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_WARN(db_options_.info_log, "Table #%s: ignoring %s",
|
|
|
|
file_num_buf, status.ToString().c_str());
|
2011-03-18 23:37:00 +01:00
|
|
|
ArchiveFile(fname);
|
|
|
|
} else {
|
|
|
|
tables_.push_back(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Status ScanTable(TableInfo* t) {
|
2016-06-25 01:29:43 +02:00
|
|
|
std::string fname = TableFileName(
|
|
|
|
db_options_.db_paths, t->meta.fd.GetNumber(), t->meta.fd.GetPathId());
|
2011-03-18 23:37:00 +01:00
|
|
|
int counter = 0;
|
2014-07-02 18:54:20 +02:00
|
|
|
uint64_t file_size;
|
|
|
|
Status status = env_->GetFileSize(fname, &file_size);
|
|
|
|
t->meta.fd = FileDescriptor(t->meta.fd.GetNumber(), t->meta.fd.GetPathId(),
|
|
|
|
file_size);
|
2016-06-24 22:12:13 +02:00
|
|
|
std::shared_ptr<const TableProperties> props;
|
|
|
|
if (status.ok()) {
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
status = table_cache_->GetTableProperties(file_options_, icmp_,
|
|
|
|
t->meta.fd, &props);
|
2016-06-24 22:12:13 +02:00
|
|
|
}
|
|
|
|
if (status.ok()) {
|
|
|
|
t->column_family_id = static_cast<uint32_t>(props->column_family_id);
|
|
|
|
if (t->column_family_id ==
|
|
|
|
TablePropertiesCollectorFactory::Context::kUnknownColumnFamily) {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_WARN(
|
|
|
|
db_options_.info_log,
|
2016-06-24 22:12:13 +02:00
|
|
|
"Table #%" PRIu64
|
|
|
|
": column family unknown (probably due to legacy format); "
|
|
|
|
"adding to default column family id 0.",
|
|
|
|
t->meta.fd.GetNumber());
|
|
|
|
t->column_family_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vset_.GetColumnFamilySet()->GetColumnFamily(t->column_family_id) ==
|
|
|
|
nullptr) {
|
|
|
|
status =
|
|
|
|
AddColumnFamily(props->column_family_name, t->column_family_id);
|
|
|
|
}
|
2019-11-23 01:01:21 +01:00
|
|
|
t->meta.oldest_ancester_time = props->creation_time;
|
2016-06-24 22:12:13 +02:00
|
|
|
}
|
2016-06-29 19:49:25 +02:00
|
|
|
ColumnFamilyData* cfd = nullptr;
|
2016-06-24 22:12:13 +02:00
|
|
|
if (status.ok()) {
|
|
|
|
cfd = vset_.GetColumnFamilySet()->GetColumnFamily(t->column_family_id);
|
|
|
|
if (cfd->GetName() != props->column_family_name) {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_ERROR(
|
|
|
|
db_options_.info_log,
|
2016-06-24 22:12:13 +02:00
|
|
|
"Table #%" PRIu64
|
|
|
|
": inconsistent column family name '%s'; expected '%s' for column "
|
|
|
|
"family id %" PRIu32 ".",
|
|
|
|
t->meta.fd.GetNumber(), props->column_family_name.c_str(),
|
|
|
|
cfd->GetName().c_str(), t->column_family_id);
|
|
|
|
status = Status::Corruption(dbname_, "inconsistent column family name");
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 23:37:00 +01:00
|
|
|
if (status.ok()) {
|
2019-04-19 20:52:13 +02:00
|
|
|
ReadOptions ropts;
|
|
|
|
ropts.total_order_seek = true;
|
2015-10-13 00:06:38 +02:00
|
|
|
InternalIterator* iter = table_cache_->NewIterator(
|
Fix use-after-free on implicit temporary FileOptions (#8571)
Summary:
FileOptions has an implicit conversion from EnvOptions and some
internal APIs take `const FileOptions&` and save the reference, which is
counter to Google C++ guidelines,
> Avoid defining functions that require a const reference parameter to outlive the call, because const reference parameters bind to temporaries. Instead, find a way to eliminate the lifetime requirement (for example, by copying the parameter), or pass it by const pointer and document the lifetime and non-null requirements.
This is at least a problem for repair.cc, which passes an EnvOptions to
TableCache(), which would save a reference to the temporary copy as
FileOptions. This was unfortunately only caught as a side effect of
changes in https://github.com/facebook/rocksdb/issues/8544.
This change fixes the repair.cc case and updates the involved internal
APIs that save a reference to use `const FileOptions*` instead.
Unfortunately, I don't know how to get any of our sanitizers to reliably
report bugs like this, so I can't rule out more existing in our
codebase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8571
Test Plan:
Test that issues seen with https://github.com/facebook/rocksdb/issues/8544 are fixed (can reproduce on
AWS EC2)
Reviewed By: ajkr
Differential Revision: D29943890
Pulled By: pdillinger
fbshipit-source-id: 95f9c5251548777b4dc994c1a083dd2add5799c9
2021-07-28 06:48:22 +02:00
|
|
|
ropts, file_options_, cfd->internal_comparator(), t->meta,
|
2018-05-21 23:33:55 +02:00
|
|
|
nullptr /* range_del_agg */,
|
2019-06-20 23:28:22 +02:00
|
|
|
cfd->GetLatestMutableCFOptions()->prefix_extractor.get(),
|
|
|
|
/*table_reader_ptr=*/nullptr, /*file_read_hist=*/nullptr,
|
|
|
|
TableReaderCaller::kRepair, /*arena=*/nullptr, /*skip_filters=*/false,
|
2020-06-10 01:49:07 +02:00
|
|
|
/*level=*/-1, /*max_file_size_for_l0_meta_pin=*/0,
|
|
|
|
/*smallest_compaction_key=*/nullptr,
|
Properly report IO errors when IndexType::kBinarySearchWithFirstKey is used (#6621)
Summary:
Context: Index type `kBinarySearchWithFirstKey` added the ability for sst file iterator to sometimes report a key from index without reading the corresponding data block. This is useful when sst blocks are cut at some meaningful boundaries (e.g. one block per key prefix), and many seeks land between blocks (e.g. for each prefix, the ranges of keys in different sst files are nearly disjoint, so a typical seek needs to read a data block from only one file even if all files have the prefix). But this added a new error condition, which rocksdb code was really not equipped to deal with: `InternalIterator::value()` may fail with an IO error or Status::Incomplete, but it's just a method returning a Slice, with no way to report error instead. Before this PR, this type of error wasn't handled at all (an empty slice was returned), and kBinarySearchWithFirstKey implementation was considered a prototype.
Now that we (LogDevice) have experimented with kBinarySearchWithFirstKey for a while and confirmed that it's really useful, this PR is adding the missing error handling.
It's a pretty inconvenient situation implementation-wise. The error needs to be reported from InternalIterator when trying to access value. But there are ~700 call sites of `InternalIterator::value()`, most of which either can't hit the error condition (because the iterator is reading from memtable or from index or something) or wouldn't benefit from the deferred loading of the value (e.g. compaction iterator that reads all values anyway). Adding error handling to all these call sites would needlessly bloat the code. So instead I made the deferred value loading optional: only the call sites that may use deferred loading have to call the new method `PrepareValue()` before calling `value()`. The feature is enabled with a new bool argument `allow_unprepared_value` to a bunch of methods that create iterators (it wouldn't make sense to put it in ReadOptions because it's completely internal to iterators, with virtually no user-visible effect). Lmk if you have better ideas.
Note that the deferred value loading only happens for *internal* iterators. The user-visible iterator (DBIter) always prepares the value before returning from Seek/Next/etc. We could go further and add an API to defer that value loading too, but that's most likely not useful for LogDevice, so it doesn't seem worth the complexity for now.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6621
Test Plan: make -j5 check . Will also deploy to some logdevice test clusters and look at stats.
Reviewed By: siying
Differential Revision: D20786930
Pulled By: al13n321
fbshipit-source-id: 6da77d918bad3780522e918f17f4d5513d3e99ee
2020-04-16 02:37:23 +02:00
|
|
|
/*largest_compaction_key=*/nullptr,
|
|
|
|
/*allow_unprepared_value=*/false);
|
2011-03-18 23:37:00 +01:00
|
|
|
ParsedInternalKey parsed;
|
|
|
|
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
|
|
|
Slice key = iter->key();
|
2020-10-28 18:11:13 +01:00
|
|
|
Status pik_status =
|
|
|
|
ParseInternalKey(key, &parsed, db_options_.allow_data_in_errors);
|
|
|
|
if (!pik_status.ok()) {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_ERROR(db_options_.info_log,
|
2020-10-28 18:11:13 +01:00
|
|
|
"Table #%" PRIu64 ": unparsable key - %s",
|
|
|
|
t->meta.fd.GetNumber(), pik_status.getState());
|
2011-03-18 23:37:00 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
counter++;
|
2019-10-15 00:19:31 +02:00
|
|
|
|
|
|
|
t->meta.UpdateBoundaries(key, iter->value(), parsed.sequence,
|
|
|
|
parsed.type);
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
if (!iter->status().ok()) {
|
|
|
|
status = iter->status();
|
|
|
|
}
|
|
|
|
delete iter;
|
2016-06-24 22:12:13 +02:00
|
|
|
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(db_options_.info_log, "Table #%" PRIu64 ": %d entries %s",
|
|
|
|
t->meta.fd.GetNumber(), counter,
|
|
|
|
status.ToString().c_str());
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
2021-07-29 01:43:16 +02:00
|
|
|
if (status.ok()) {
|
|
|
|
// XXX/FIXME: This is just basic, naive handling of range tombstones,
|
|
|
|
// like call to UpdateBoundariesForRange in builder.cc where we assume
|
|
|
|
// an SST file is a full sorted run. This probably needs the extra logic
|
|
|
|
// from compaction_job.cc around call to UpdateBoundariesForRange (to
|
|
|
|
// handle range tombstones extendingg beyond range of other entries).
|
|
|
|
ReadOptions ropts;
|
|
|
|
std::unique_ptr<FragmentedRangeTombstoneIterator> r_iter;
|
|
|
|
status = table_cache_->GetRangeTombstoneIterator(
|
|
|
|
ropts, cfd->internal_comparator(), t->meta, &r_iter);
|
|
|
|
|
|
|
|
if (r_iter) {
|
|
|
|
r_iter->SeekToFirst();
|
|
|
|
|
|
|
|
while (r_iter->Valid()) {
|
|
|
|
auto tombstone = r_iter->Tombstone();
|
|
|
|
auto kv = tombstone.Serialize();
|
|
|
|
t->meta.UpdateBoundariesForRange(
|
|
|
|
kv.first, tombstone.SerializeEndKey(), tombstone.seq_,
|
|
|
|
cfd->internal_comparator());
|
|
|
|
r_iter->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 23:37:00 +01:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2016-06-24 20:19:40 +02:00
|
|
|
Status AddTables() {
|
2016-06-24 22:12:13 +02:00
|
|
|
std::unordered_map<uint32_t, std::vector<const TableInfo*>> cf_id_to_tables;
|
2011-03-18 23:37:00 +01:00
|
|
|
SequenceNumber max_sequence = 0;
|
2011-04-21 00:48:11 +02:00
|
|
|
for (size_t i = 0; i < tables_.size(); i++) {
|
2016-06-24 22:12:13 +02:00
|
|
|
cf_id_to_tables[tables_[i].column_family_id].push_back(&tables_[i]);
|
2019-10-15 00:19:31 +02:00
|
|
|
if (max_sequence < tables_[i].meta.fd.largest_seqno) {
|
|
|
|
max_sequence = tables_[i].meta.fd.largest_seqno;
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-11 02:18:01 +01:00
|
|
|
vset_.SetLastAllocatedSequence(max_sequence);
|
2017-12-01 08:39:56 +01:00
|
|
|
vset_.SetLastPublishedSequence(max_sequence);
|
2016-06-24 20:19:40 +02:00
|
|
|
vset_.SetLastSequence(max_sequence);
|
|
|
|
|
2016-06-24 22:12:13 +02:00
|
|
|
for (const auto& cf_id_and_tables : cf_id_to_tables) {
|
|
|
|
auto* cfd =
|
|
|
|
vset_.GetColumnFamilySet()->GetColumnFamily(cf_id_and_tables.first);
|
|
|
|
VersionEdit edit;
|
|
|
|
edit.SetComparatorName(cfd->user_comparator()->Name());
|
|
|
|
edit.SetLogNumber(0);
|
|
|
|
edit.SetNextFile(next_file_number_);
|
|
|
|
edit.SetColumnFamily(cfd->GetID());
|
|
|
|
|
|
|
|
// TODO(opt): separate out into multiple levels
|
|
|
|
for (const auto* table : cf_id_and_tables.second) {
|
2019-11-27 06:38:38 +01:00
|
|
|
edit.AddFile(
|
|
|
|
0, table->meta.fd.GetNumber(), table->meta.fd.GetPathId(),
|
|
|
|
table->meta.fd.GetFileSize(), table->meta.smallest,
|
|
|
|
table->meta.largest, table->meta.fd.smallest_seqno,
|
|
|
|
table->meta.fd.largest_seqno, table->meta.marked_for_compaction,
|
|
|
|
table->meta.oldest_blob_file_number,
|
2020-02-11 00:42:46 +01:00
|
|
|
table->meta.oldest_ancester_time, table->meta.file_creation_time,
|
|
|
|
table->meta.file_checksum, table->meta.file_checksum_func_name);
|
2016-06-24 22:12:13 +02:00
|
|
|
}
|
2017-10-10 22:07:00 +02:00
|
|
|
assert(next_file_number_ > 0);
|
|
|
|
vset_.MarkFileNumberUsed(next_file_number_ - 1);
|
2016-06-24 22:12:13 +02:00
|
|
|
mutex_.Lock();
|
|
|
|
Status status = vset_.LogAndApply(
|
|
|
|
cfd, *cfd->GetLatestMutableCFOptions(), &edit, &mutex_,
|
|
|
|
nullptr /* db_directory */, false /* new_descriptor_log */);
|
|
|
|
mutex_.Unlock();
|
|
|
|
if (!status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
2016-06-24 22:12:13 +02:00
|
|
|
return Status::OK();
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ArchiveFile(const std::string& fname) {
|
|
|
|
// Move into another directory. E.g., for
|
|
|
|
// dir/foo
|
|
|
|
// rename to
|
|
|
|
// dir/lost/foo
|
|
|
|
const char* slash = strrchr(fname.c_str(), '/');
|
|
|
|
std::string new_dir;
|
2013-03-01 03:04:58 +01:00
|
|
|
if (slash != nullptr) {
|
2011-03-18 23:37:00 +01:00
|
|
|
new_dir.assign(fname.data(), slash - fname.data());
|
|
|
|
}
|
|
|
|
new_dir.append("/lost");
|
2020-09-30 01:28:42 +02:00
|
|
|
env_->CreateDir(new_dir).PermitUncheckedError(); // Ignore error
|
2011-03-18 23:37:00 +01:00
|
|
|
std::string new_file = new_dir;
|
|
|
|
new_file.append("/");
|
2013-03-01 03:04:58 +01:00
|
|
|
new_file.append((slash == nullptr) ? fname.c_str() : slash + 1);
|
2011-03-18 23:37:00 +01:00
|
|
|
Status s = env_->RenameFile(fname, new_file);
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_INFO(db_options_.info_log, "Archiving %s: %s\n", fname.c_str(),
|
|
|
|
s.ToString().c_str());
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
};
|
2016-06-25 01:29:43 +02:00
|
|
|
|
|
|
|
Status GetDefaultCFOptions(
|
|
|
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
|
|
|
ColumnFamilyOptions* res) {
|
|
|
|
assert(res != nullptr);
|
|
|
|
auto iter = std::find_if(column_families.begin(), column_families.end(),
|
|
|
|
[](const ColumnFamilyDescriptor& cfd) {
|
|
|
|
return cfd.name == kDefaultColumnFamilyName;
|
|
|
|
});
|
|
|
|
if (iter == column_families.end()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"column_families", "Must contain entry for default column family");
|
|
|
|
}
|
|
|
|
*res = iter->options;
|
|
|
|
return Status::OK();
|
|
|
|
}
|
2016-06-24 20:19:40 +02:00
|
|
|
} // anonymous namespace
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2016-06-25 01:29:43 +02:00
|
|
|
Status RepairDB(const std::string& dbname, const DBOptions& db_options,
|
2017-09-28 02:37:08 +02:00
|
|
|
const std::vector<ColumnFamilyDescriptor>& column_families
|
|
|
|
) {
|
2016-06-25 01:29:43 +02:00
|
|
|
ColumnFamilyOptions default_cf_opts;
|
|
|
|
Status status = GetDefaultCFOptions(column_families, &default_cf_opts);
|
2020-09-30 01:28:42 +02:00
|
|
|
if (!status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Repairer repairer(dbname, db_options, column_families, default_cf_opts,
|
|
|
|
ColumnFamilyOptions() /* unknown_cf_opts */,
|
|
|
|
false /* create_unknown_cfs */);
|
|
|
|
status = repairer.Run();
|
2016-06-25 01:29:43 +02:00
|
|
|
if (status.ok()) {
|
2020-09-30 01:28:42 +02:00
|
|
|
status = repairer.Close();
|
2016-06-25 01:29:43 +02:00
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RepairDB(const std::string& dbname, const DBOptions& db_options,
|
|
|
|
const std::vector<ColumnFamilyDescriptor>& column_families,
|
|
|
|
const ColumnFamilyOptions& unknown_cf_opts) {
|
|
|
|
ColumnFamilyOptions default_cf_opts;
|
|
|
|
Status status = GetDefaultCFOptions(column_families, &default_cf_opts);
|
2020-09-30 01:28:42 +02:00
|
|
|
if (!status.ok()) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Repairer repairer(dbname, db_options, column_families, default_cf_opts,
|
|
|
|
unknown_cf_opts, true /* create_unknown_cfs */);
|
|
|
|
status = repairer.Run();
|
2016-06-25 01:29:43 +02:00
|
|
|
if (status.ok()) {
|
2020-09-30 01:28:42 +02:00
|
|
|
status = repairer.Close();
|
2016-06-25 01:29:43 +02:00
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
Status RepairDB(const std::string& dbname, const Options& options) {
|
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
|
|
|
Options opts(options);
|
|
|
|
DBOptions db_options(opts);
|
|
|
|
ColumnFamilyOptions cf_options(opts);
|
2020-09-30 01:28:42 +02:00
|
|
|
|
2017-09-28 02:37:08 +02:00
|
|
|
Repairer repairer(dbname, db_options,
|
|
|
|
{}, cf_options /* default_cf_opts */,
|
2016-06-25 01:29:43 +02:00
|
|
|
cf_options /* unknown_cf_opts */,
|
|
|
|
true /* create_unknown_cfs */);
|
2020-09-30 01:28:42 +02:00
|
|
|
Status status = repairer.Run();
|
|
|
|
if (status.ok()) {
|
|
|
|
status = repairer.Close();
|
|
|
|
}
|
|
|
|
return status;
|
2011-03-18 23:37:00 +01:00
|
|
|
}
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
2014-04-15 22:39:26 +02:00
|
|
|
|
|
|
|
#endif // ROCKSDB_LITE
|