2016-02-09 23:12:00 +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).
|
2015-07-13 23:53:38 +00: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.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
2016-01-29 02:35:01 +00:00
|
|
|
#include <map>
|
2015-07-13 23:53:38 +00:00
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "db/db_impl.h"
|
|
|
|
#include "db/dbformat.h"
|
2017-04-06 02:02:00 +00:00
|
|
|
#include "env/mock_env.h"
|
2015-10-16 21:10:33 +00:00
|
|
|
#include "memtable/hash_linklist_rep.h"
|
2015-07-13 23:53:38 +00:00
|
|
|
#include "rocksdb/cache.h"
|
|
|
|
#include "rocksdb/compaction_filter.h"
|
2015-07-17 18:04:55 +00:00
|
|
|
#include "rocksdb/convenience.h"
|
2015-07-13 23:53:38 +00:00
|
|
|
#include "rocksdb/db.h"
|
|
|
|
#include "rocksdb/env.h"
|
|
|
|
#include "rocksdb/filter_policy.h"
|
|
|
|
#include "rocksdb/options.h"
|
|
|
|
#include "rocksdb/slice.h"
|
2016-06-22 00:57:59 +00:00
|
|
|
#include "rocksdb/sst_file_writer.h"
|
2016-04-18 16:42:50 +00:00
|
|
|
#include "rocksdb/statistics.h"
|
2015-07-13 23:53:38 +00:00
|
|
|
#include "rocksdb/table.h"
|
|
|
|
#include "rocksdb/utilities/checkpoint.h"
|
|
|
|
#include "table/block_based_table_factory.h"
|
|
|
|
#include "table/mock_table.h"
|
|
|
|
#include "table/plain_table_factory.h"
|
2015-10-12 22:06:38 +00:00
|
|
|
#include "table/scoped_arena_iterator.h"
|
2015-07-13 23:53:38 +00:00
|
|
|
#include "util/compression.h"
|
2017-04-04 01:27:24 +00:00
|
|
|
#include "util/filename.h"
|
2018-10-22 03:14:58 +00:00
|
|
|
#include "util/mock_time_env.h"
|
2015-07-13 23:53:38 +00:00
|
|
|
#include "util/mutexlock.h"
|
2015-10-12 22:06:38 +00:00
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
#include "util/string_util.h"
|
|
|
|
#include "util/sync_point.h"
|
|
|
|
#include "util/testharness.h"
|
|
|
|
#include "util/testutil.h"
|
|
|
|
#include "utilities/merge_operators.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
namespace anon {
|
|
|
|
class AtomicCounter {
|
|
|
|
public:
|
|
|
|
explicit AtomicCounter(Env* env = NULL)
|
|
|
|
: env_(env), cond_count_(&mu_), count_(0) {}
|
|
|
|
|
|
|
|
void Increment() {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
count_++;
|
|
|
|
cond_count_.SignalAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Read() {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
return count_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WaitFor(int count) {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
|
|
|
|
uint64_t start = env_->NowMicros();
|
|
|
|
while (count_ < count) {
|
|
|
|
uint64_t now = env_->NowMicros();
|
2015-09-16 20:04:05 +00:00
|
|
|
cond_count_.TimedWait(now + /*1s*/ 1 * 1000 * 1000);
|
|
|
|
if (env_->NowMicros() - start > /*10s*/ 10 * 1000 * 1000) {
|
2015-07-13 23:53:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (count_ < count) {
|
|
|
|
GTEST_LOG_(WARNING) << "WaitFor is taking more time than usual";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
MutexLock l(&mu_);
|
|
|
|
count_ = 0;
|
|
|
|
cond_count_.SignalAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Env* env_;
|
|
|
|
port::Mutex mu_;
|
|
|
|
port::CondVar cond_count_;
|
|
|
|
int count_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OptionsOverride {
|
|
|
|
std::shared_ptr<const FilterPolicy> filter_policy = nullptr;
|
2017-03-22 16:11:23 +00:00
|
|
|
// These will be used only if filter_policy is set
|
|
|
|
bool partition_filters = false;
|
2017-03-28 18:56:56 +00:00
|
|
|
uint64_t metadata_block_size = 1024;
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
// Used as a bit mask of individual enums in which to skip an XF test point
|
|
|
|
int skip_policy = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2017-02-23 20:03:28 +00:00
|
|
|
enum SkipPolicy { kSkipNone = 0, kSkipNoSnapshot = 1, kSkipNoPrefix = 2 };
|
|
|
|
|
2015-11-30 19:41:53 +00:00
|
|
|
// A hacky skip list mem table that triggers flush after number of entries.
|
|
|
|
class SpecialMemTableRep : public MemTableRep {
|
|
|
|
public:
|
2017-06-02 21:13:59 +00:00
|
|
|
explicit SpecialMemTableRep(Allocator* allocator, MemTableRep* memtable,
|
|
|
|
int num_entries_flush)
|
2015-11-30 19:41:53 +00:00
|
|
|
: MemTableRep(allocator),
|
|
|
|
memtable_(memtable),
|
|
|
|
num_entries_flush_(num_entries_flush),
|
|
|
|
num_entries_(0) {}
|
|
|
|
|
|
|
|
virtual KeyHandle Allocate(const size_t len, char** buf) override {
|
|
|
|
return memtable_->Allocate(len, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert key into the list.
|
|
|
|
// REQUIRES: nothing that compares equal to key is currently in the list.
|
2018-02-16 01:12:48 +00:00
|
|
|
virtual void Insert(KeyHandle handle) override {
|
2015-11-30 19:41:53 +00:00
|
|
|
num_entries_++;
|
2018-02-16 01:12:48 +00:00
|
|
|
memtable_->Insert(handle);
|
2015-11-30 19:41:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true iff an entry that compares equal to key is in the list.
|
|
|
|
virtual bool Contains(const char* key) const override {
|
|
|
|
return memtable_->Contains(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual size_t ApproximateMemoryUsage() override {
|
|
|
|
// Return a high memory usage when number of entries exceeds the threshold
|
|
|
|
// to trigger a flush.
|
|
|
|
return (num_entries_ < num_entries_flush_) ? 0 : 1024 * 1024 * 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Get(const LookupKey& k, void* callback_args,
|
|
|
|
bool (*callback_func)(void* arg,
|
|
|
|
const char* entry)) override {
|
|
|
|
memtable_->Get(k, callback_args, callback_func);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t ApproximateNumEntries(const Slice& start_ikey,
|
|
|
|
const Slice& end_ikey) override {
|
|
|
|
return memtable_->ApproximateNumEntries(start_ikey, end_ikey);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual MemTableRep::Iterator* GetIterator(Arena* arena = nullptr) override {
|
|
|
|
return memtable_->GetIterator(arena);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~SpecialMemTableRep() override {}
|
|
|
|
|
|
|
|
private:
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<MemTableRep> memtable_;
|
2015-11-30 19:41:53 +00:00
|
|
|
int num_entries_flush_;
|
|
|
|
int num_entries_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// The factory for the hacky skip list mem table that triggers flush after
|
|
|
|
// number of entries exceeds a threshold.
|
|
|
|
class SpecialSkipListFactory : public MemTableRepFactory {
|
|
|
|
public:
|
|
|
|
// After number of inserts exceeds `num_entries_flush` in a mem table, trigger
|
|
|
|
// flush.
|
|
|
|
explicit SpecialSkipListFactory(int num_entries_flush)
|
|
|
|
: num_entries_flush_(num_entries_flush) {}
|
|
|
|
|
2017-06-02 19:08:01 +00:00
|
|
|
using MemTableRepFactory::CreateMemTableRep;
|
2015-11-30 19:41:53 +00:00
|
|
|
virtual MemTableRep* CreateMemTableRep(
|
2017-06-02 21:13:59 +00:00
|
|
|
const MemTableRep::KeyComparator& compare, Allocator* allocator,
|
2018-03-05 21:08:17 +00:00
|
|
|
const SliceTransform* transform, Logger* /*logger*/) override {
|
2015-11-30 19:41:53 +00:00
|
|
|
return new SpecialMemTableRep(
|
|
|
|
allocator, factory_.CreateMemTableRep(compare, allocator, transform, 0),
|
|
|
|
num_entries_flush_);
|
|
|
|
}
|
|
|
|
virtual const char* Name() const override { return "SkipListFactory"; }
|
|
|
|
|
2016-11-16 17:24:52 +00:00
|
|
|
bool IsInsertConcurrentlySupported() const override {
|
|
|
|
return factory_.IsInsertConcurrentlySupported();
|
|
|
|
}
|
|
|
|
|
2015-11-30 19:41:53 +00:00
|
|
|
private:
|
|
|
|
SkipListFactory factory_;
|
|
|
|
int num_entries_flush_;
|
|
|
|
};
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
// Special Env used to delay background operations
|
|
|
|
class SpecialEnv : public EnvWrapper {
|
|
|
|
public:
|
|
|
|
explicit SpecialEnv(Env* base);
|
|
|
|
|
2018-11-09 19:17:34 +00:00
|
|
|
Status NewWritableFile(const std::string& f, std::unique_ptr<WritableFile>* r,
|
2015-07-13 23:53:38 +00:00
|
|
|
const EnvOptions& soptions) override {
|
|
|
|
class SSTableFile : public WritableFile {
|
|
|
|
private:
|
|
|
|
SpecialEnv* env_;
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<WritableFile> base_;
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
public:
|
2018-11-09 19:17:34 +00:00
|
|
|
SSTableFile(SpecialEnv* env, std::unique_ptr<WritableFile>&& base)
|
2015-10-12 22:06:38 +00:00
|
|
|
: env_(env), base_(std::move(base)) {}
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Append(const Slice& data) override {
|
|
|
|
if (env_->table_write_callback_) {
|
|
|
|
(*env_->table_write_callback_)();
|
|
|
|
}
|
|
|
|
if (env_->drop_writes_.load(std::memory_order_acquire)) {
|
|
|
|
// Drop writes on the floor
|
|
|
|
return Status::OK();
|
|
|
|
} else if (env_->no_space_.load(std::memory_order_acquire)) {
|
2016-09-07 19:37:45 +00:00
|
|
|
return Status::NoSpace("No space left on device");
|
2015-07-13 23:53:38 +00:00
|
|
|
} else {
|
|
|
|
env_->bytes_written_ += data.size();
|
|
|
|
return base_->Append(data);
|
|
|
|
}
|
|
|
|
}
|
2017-02-22 18:21:39 +00:00
|
|
|
Status PositionedAppend(const Slice& data, uint64_t offset) override {
|
2017-02-22 18:00:25 +00:00
|
|
|
if (env_->table_write_callback_) {
|
|
|
|
(*env_->table_write_callback_)();
|
|
|
|
}
|
|
|
|
if (env_->drop_writes_.load(std::memory_order_acquire)) {
|
|
|
|
// Drop writes on the floor
|
|
|
|
return Status::OK();
|
|
|
|
} else if (env_->no_space_.load(std::memory_order_acquire)) {
|
|
|
|
return Status::NoSpace("No space left on device");
|
|
|
|
} else {
|
|
|
|
env_->bytes_written_ += data.size();
|
|
|
|
return base_->PositionedAppend(data, offset);
|
|
|
|
}
|
|
|
|
}
|
2015-10-12 22:06:38 +00:00
|
|
|
Status Truncate(uint64_t size) override { return base_->Truncate(size); }
|
2017-06-26 20:15:55 +00:00
|
|
|
Status RangeSync(uint64_t offset, uint64_t nbytes) override {
|
|
|
|
Status s = base_->RangeSync(offset, nbytes);
|
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
TEST_SYNC_POINT_CALLBACK("SpecialEnv::SStableFile::RangeSync", &s);
|
|
|
|
#endif // !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
return s;
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Close() override {
|
2015-07-14 23:02:31 +00:00
|
|
|
// SyncPoint is not supported in Released Windows Mode.
|
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
2015-07-13 23:53:38 +00:00
|
|
|
// Check preallocation size
|
|
|
|
// preallocation size is never passed to base file.
|
|
|
|
size_t preallocation_size = preallocation_block_size();
|
|
|
|
TEST_SYNC_POINT_CALLBACK("DBTestWritableFile.GetPreallocationStatus",
|
|
|
|
&preallocation_size);
|
2015-07-14 23:02:31 +00:00
|
|
|
#endif // !(defined NDEBUG) || !defined(OS_WIN)
|
2017-06-26 20:15:55 +00:00
|
|
|
Status s = base_->Close();
|
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
TEST_SYNC_POINT_CALLBACK("SpecialEnv::SStableFile::Close", &s);
|
|
|
|
#endif // !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
return s;
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
|
|
|
Status Flush() override { return base_->Flush(); }
|
|
|
|
Status Sync() override {
|
|
|
|
++env_->sync_counter_;
|
|
|
|
while (env_->delay_sstable_sync_.load(std::memory_order_acquire)) {
|
|
|
|
env_->SleepForMicroseconds(100000);
|
|
|
|
}
|
2017-06-26 20:15:55 +00:00
|
|
|
Status s = base_->Sync();
|
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
TEST_SYNC_POINT_CALLBACK("SpecialEnv::SStableFile::Sync", &s);
|
|
|
|
#endif // !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
return s;
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
|
|
|
void SetIOPriority(Env::IOPriority pri) override {
|
|
|
|
base_->SetIOPriority(pri);
|
|
|
|
}
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-17 23:16:11 +00:00
|
|
|
Env::IOPriority GetIOPriority() override {
|
|
|
|
return base_->GetIOPriority();
|
|
|
|
}
|
2017-02-22 18:00:25 +00:00
|
|
|
bool use_direct_io() const override {
|
|
|
|
return base_->use_direct_io();
|
|
|
|
}
|
2017-05-05 00:40:29 +00:00
|
|
|
Status Allocate(uint64_t offset, uint64_t len) override {
|
|
|
|
return base_->Allocate(offset, len);
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
class ManifestFile : public WritableFile {
|
|
|
|
public:
|
2018-11-09 19:17:34 +00:00
|
|
|
ManifestFile(SpecialEnv* env, std::unique_ptr<WritableFile>&& b)
|
2015-10-12 22:06:38 +00:00
|
|
|
: env_(env), base_(std::move(b)) {}
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Append(const Slice& data) override {
|
|
|
|
if (env_->manifest_write_error_.load(std::memory_order_acquire)) {
|
|
|
|
return Status::IOError("simulated writer error");
|
|
|
|
} else {
|
|
|
|
return base_->Append(data);
|
|
|
|
}
|
|
|
|
}
|
2015-09-11 16:57:02 +00:00
|
|
|
Status Truncate(uint64_t size) override { return base_->Truncate(size); }
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Close() override { return base_->Close(); }
|
|
|
|
Status Flush() override { return base_->Flush(); }
|
|
|
|
Status Sync() override {
|
|
|
|
++env_->sync_counter_;
|
|
|
|
if (env_->manifest_sync_error_.load(std::memory_order_acquire)) {
|
|
|
|
return Status::IOError("simulated sync error");
|
|
|
|
} else {
|
|
|
|
return base_->Sync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint64_t GetFileSize() override { return base_->GetFileSize(); }
|
2018-09-26 17:34:56 +00:00
|
|
|
Status Allocate(uint64_t offset, uint64_t len) override {
|
|
|
|
return base_->Allocate(offset, len);
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SpecialEnv* env_;
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<WritableFile> base_;
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
class WalFile : public WritableFile {
|
|
|
|
public:
|
2018-11-09 19:17:34 +00:00
|
|
|
WalFile(SpecialEnv* env, std::unique_ptr<WritableFile>&& b)
|
2016-08-04 00:42:06 +00:00
|
|
|
: env_(env), base_(std::move(b)) {
|
|
|
|
env_->num_open_wal_file_.fetch_add(1);
|
|
|
|
}
|
|
|
|
virtual ~WalFile() { env_->num_open_wal_file_.fetch_add(-1); }
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Append(const Slice& data) override {
|
2015-08-05 18:56:19 +00:00
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
TEST_SYNC_POINT("SpecialEnv::WalFile::Append:1");
|
|
|
|
#endif
|
|
|
|
Status s;
|
2015-07-13 23:53:38 +00:00
|
|
|
if (env_->log_write_error_.load(std::memory_order_acquire)) {
|
2015-08-05 18:56:19 +00:00
|
|
|
s = Status::IOError("simulated writer error");
|
2015-07-13 23:53:38 +00:00
|
|
|
} else {
|
|
|
|
int slowdown =
|
|
|
|
env_->log_write_slowdown_.load(std::memory_order_acquire);
|
|
|
|
if (slowdown > 0) {
|
|
|
|
env_->SleepForMicroseconds(slowdown);
|
|
|
|
}
|
2015-08-05 18:56:19 +00:00
|
|
|
s = base_->Append(data);
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
2015-08-05 18:56:19 +00:00
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
TEST_SYNC_POINT("SpecialEnv::WalFile::Append:2");
|
|
|
|
#endif
|
|
|
|
return s;
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
2015-09-11 16:57:02 +00:00
|
|
|
Status Truncate(uint64_t size) override { return base_->Truncate(size); }
|
2016-09-13 23:38:28 +00:00
|
|
|
Status Close() override {
|
|
|
|
// SyncPoint is not supported in Released Windows Mode.
|
|
|
|
#if !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
// Check preallocation size
|
|
|
|
// preallocation size is never passed to base file.
|
|
|
|
size_t preallocation_size = preallocation_block_size();
|
|
|
|
TEST_SYNC_POINT_CALLBACK("DBTestWalFile.GetPreallocationStatus",
|
|
|
|
&preallocation_size);
|
|
|
|
#endif // !(defined NDEBUG) || !defined(OS_WIN)
|
|
|
|
|
|
|
|
return base_->Close();
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Flush() override { return base_->Flush(); }
|
|
|
|
Status Sync() override {
|
|
|
|
++env_->sync_counter_;
|
|
|
|
return base_->Sync();
|
|
|
|
}
|
[wal changes 3/3] method in DB to sync WAL without blocking writers
Summary:
Subj. We really need this feature.
Previous diff D40899 has most of the changes to make this possible, this diff just adds the method.
Test Plan: `make check`, the new test fails without this diff; ran with ASAN, TSAN and valgrind.
Reviewers: igor, rven, IslamAbdelRahman, anthony, kradhakrishnan, tnovak, yhchiang, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, maykov, hermanlee4, yoshinorim, tnovak, dhruba
Differential Revision: https://reviews.facebook.net/D40905
2015-08-05 13:06:39 +00:00
|
|
|
bool IsSyncThreadSafe() const override {
|
|
|
|
return env_->is_wal_sync_thread_safe_.load();
|
|
|
|
}
|
2018-09-26 17:34:56 +00:00
|
|
|
Status Allocate(uint64_t offset, uint64_t len) override {
|
|
|
|
return base_->Allocate(offset, len);
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SpecialEnv* env_;
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<WritableFile> base_;
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (non_writeable_rate_.load(std::memory_order_acquire) > 0) {
|
|
|
|
uint32_t random_number;
|
|
|
|
{
|
|
|
|
MutexLock l(&rnd_mutex_);
|
|
|
|
random_number = rnd_.Uniform(100);
|
|
|
|
}
|
|
|
|
if (random_number < non_writeable_rate_.load()) {
|
|
|
|
return Status::IOError("simulated random write error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new_writable_count_++;
|
|
|
|
|
|
|
|
if (non_writable_count_.load() > 0) {
|
|
|
|
non_writable_count_--;
|
|
|
|
return Status::IOError("simulated write error");
|
|
|
|
}
|
|
|
|
|
2017-02-22 18:00:25 +00:00
|
|
|
EnvOptions optimized = soptions;
|
|
|
|
if (strstr(f.c_str(), "MANIFEST") != nullptr ||
|
|
|
|
strstr(f.c_str(), "log") != nullptr) {
|
|
|
|
optimized.use_mmap_writes = false;
|
|
|
|
optimized.use_direct_writes = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status s = target()->NewWritableFile(f, r, optimized);
|
2015-07-13 23:53:38 +00:00
|
|
|
if (s.ok()) {
|
|
|
|
if (strstr(f.c_str(), ".sst") != nullptr) {
|
|
|
|
r->reset(new SSTableFile(this, std::move(*r)));
|
|
|
|
} else if (strstr(f.c_str(), "MANIFEST") != nullptr) {
|
|
|
|
r->reset(new ManifestFile(this, std::move(*r)));
|
|
|
|
} else if (strstr(f.c_str(), "log") != nullptr) {
|
|
|
|
r->reset(new WalFile(this, std::move(*r)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status NewRandomAccessFile(const std::string& f,
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<RandomAccessFile>* r,
|
2015-07-13 23:53:38 +00:00
|
|
|
const EnvOptions& soptions) override {
|
|
|
|
class CountingFile : public RandomAccessFile {
|
|
|
|
public:
|
2018-11-09 19:17:34 +00:00
|
|
|
CountingFile(std::unique_ptr<RandomAccessFile>&& target,
|
2016-05-04 22:25:58 +00:00
|
|
|
anon::AtomicCounter* counter,
|
2016-05-09 18:52:28 +00:00
|
|
|
std::atomic<size_t>* bytes_read)
|
2016-05-04 22:25:58 +00:00
|
|
|
: target_(std::move(target)),
|
|
|
|
counter_(counter),
|
|
|
|
bytes_read_(bytes_read) {}
|
2015-07-13 23:53:38 +00:00
|
|
|
virtual Status Read(uint64_t offset, size_t n, Slice* result,
|
|
|
|
char* scratch) const override {
|
|
|
|
counter_->Increment();
|
2016-05-04 22:25:58 +00:00
|
|
|
Status s = target_->Read(offset, n, result, scratch);
|
|
|
|
*bytes_read_ += result->size();
|
|
|
|
return s;
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<RandomAccessFile> target_;
|
2015-07-13 23:53:38 +00:00
|
|
|
anon::AtomicCounter* counter_;
|
2016-05-09 18:52:28 +00:00
|
|
|
std::atomic<size_t>* bytes_read_;
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Status s = target()->NewRandomAccessFile(f, r, soptions);
|
2015-08-04 20:48:16 +00:00
|
|
|
random_file_open_counter_++;
|
2015-07-13 23:53:38 +00:00
|
|
|
if (s.ok() && count_random_reads_) {
|
2016-05-04 22:25:58 +00:00
|
|
|
r->reset(new CountingFile(std::move(*r), &random_read_counter_,
|
|
|
|
&random_read_bytes_counter_));
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
2017-11-17 01:46:43 +00:00
|
|
|
if (s.ok() && soptions.compaction_readahead_size > 0) {
|
|
|
|
compaction_readahead_size_ = soptions.compaction_readahead_size;
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
Skip deleted WALs during recovery
Summary:
This patch record min log number to keep to the manifest while flushing SST files to ignore them and any WAL older than them during recovery. This is to avoid scenarios when we have a gap between the WAL files are fed to the recovery procedure. The gap could happen by for example out-of-order WAL deletion. Such gap could cause problems in 2PC recovery where the prepared and commit entry are placed into two separate WAL and gap in the WALs could result into not processing the WAL with the commit entry and hence breaking the 2PC recovery logic.
Before the commit, for 2PC case, we determined which log number to keep in FindObsoleteFiles(). We looked at the earliest logs with outstanding prepare entries, or prepare entries whose respective commit or abort are in memtable. With the commit, the same calculation is done while we apply the SST flush. Just before installing the flush file, we precompute the earliest log file to keep after the flush finishes using the same logic (but skipping the memtables just flushed), record this information to the manifest entry for this new flushed SST file. This pre-computed value is also remembered in memory, and will later be used to determine whether a log file can be deleted. This value is unlikely to change until next flush because the commit entry will stay in memtable. (In WritePrepared, we could have removed the older log files as soon as all prepared entries are committed. It's not yet done anyway. Even if we do it, the only thing we loss with this new approach is earlier log deletion between two flushes, which does not guarantee to happen anyway because the obsolete file clean-up function is only executed after flush or compaction)
This min log number to keep is stored in the manifest using the safely-ignore customized field of AddFile entry, in order to guarantee that the DB generated using newer release can be opened by previous releases no older than 4.2.
Closes https://github.com/facebook/rocksdb/pull/3765
Differential Revision: D7747618
Pulled By: siying
fbshipit-source-id: d00c92105b4f83852e9754a1b70d6b64cb590729
2018-05-03 22:35:11 +00:00
|
|
|
virtual Status NewSequentialFile(const std::string& f,
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<SequentialFile>* r,
|
Skip deleted WALs during recovery
Summary:
This patch record min log number to keep to the manifest while flushing SST files to ignore them and any WAL older than them during recovery. This is to avoid scenarios when we have a gap between the WAL files are fed to the recovery procedure. The gap could happen by for example out-of-order WAL deletion. Such gap could cause problems in 2PC recovery where the prepared and commit entry are placed into two separate WAL and gap in the WALs could result into not processing the WAL with the commit entry and hence breaking the 2PC recovery logic.
Before the commit, for 2PC case, we determined which log number to keep in FindObsoleteFiles(). We looked at the earliest logs with outstanding prepare entries, or prepare entries whose respective commit or abort are in memtable. With the commit, the same calculation is done while we apply the SST flush. Just before installing the flush file, we precompute the earliest log file to keep after the flush finishes using the same logic (but skipping the memtables just flushed), record this information to the manifest entry for this new flushed SST file. This pre-computed value is also remembered in memory, and will later be used to determine whether a log file can be deleted. This value is unlikely to change until next flush because the commit entry will stay in memtable. (In WritePrepared, we could have removed the older log files as soon as all prepared entries are committed. It's not yet done anyway. Even if we do it, the only thing we loss with this new approach is earlier log deletion between two flushes, which does not guarantee to happen anyway because the obsolete file clean-up function is only executed after flush or compaction)
This min log number to keep is stored in the manifest using the safely-ignore customized field of AddFile entry, in order to guarantee that the DB generated using newer release can be opened by previous releases no older than 4.2.
Closes https://github.com/facebook/rocksdb/pull/3765
Differential Revision: D7747618
Pulled By: siying
fbshipit-source-id: d00c92105b4f83852e9754a1b70d6b64cb590729
2018-05-03 22:35:11 +00:00
|
|
|
const EnvOptions& soptions) override {
|
2015-07-13 23:53:38 +00:00
|
|
|
class CountingFile : public SequentialFile {
|
|
|
|
public:
|
2018-11-09 19:17:34 +00:00
|
|
|
CountingFile(std::unique_ptr<SequentialFile>&& target,
|
2015-07-13 23:53:38 +00:00
|
|
|
anon::AtomicCounter* counter)
|
|
|
|
: target_(std::move(target)), counter_(counter) {}
|
|
|
|
virtual Status Read(size_t n, Slice* result, char* scratch) override {
|
|
|
|
counter_->Increment();
|
|
|
|
return target_->Read(n, result, scratch);
|
|
|
|
}
|
|
|
|
virtual Status Skip(uint64_t n) override { return target_->Skip(n); }
|
|
|
|
|
|
|
|
private:
|
2018-11-09 19:17:34 +00:00
|
|
|
std::unique_ptr<SequentialFile> target_;
|
2015-07-13 23:53:38 +00:00
|
|
|
anon::AtomicCounter* counter_;
|
|
|
|
};
|
|
|
|
|
|
|
|
Status s = target()->NewSequentialFile(f, r, soptions);
|
|
|
|
if (s.ok() && count_sequential_reads_) {
|
|
|
|
r->reset(new CountingFile(std::move(*r), &sequential_read_counter_));
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SleepForMicroseconds(int micros) override {
|
|
|
|
sleep_counter_.Increment();
|
2016-11-22 01:56:19 +00:00
|
|
|
if (no_slowdown_ || time_elapse_only_sleep_) {
|
2015-07-13 23:53:38 +00:00
|
|
|
addon_time_.fetch_add(micros);
|
2015-11-17 19:06:15 +00:00
|
|
|
}
|
2016-11-22 01:56:19 +00:00
|
|
|
if (!no_slowdown_) {
|
2015-07-13 23:53:38 +00:00
|
|
|
target()->SleepForMicroseconds(micros);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Status GetCurrentTime(int64_t* unix_time) override {
|
2015-11-17 19:06:15 +00:00
|
|
|
Status s;
|
|
|
|
if (!time_elapse_only_sleep_) {
|
|
|
|
s = target()->GetCurrentTime(unix_time);
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
if (s.ok()) {
|
|
|
|
*unix_time += addon_time_.load();
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual uint64_t NowNanos() override {
|
2015-11-17 19:06:15 +00:00
|
|
|
return (time_elapse_only_sleep_ ? 0 : target()->NowNanos()) +
|
|
|
|
addon_time_.load() * 1000;
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual uint64_t NowMicros() override {
|
2015-11-17 19:06:15 +00:00
|
|
|
return (time_elapse_only_sleep_ ? 0 : target()->NowMicros()) +
|
|
|
|
addon_time_.load();
|
2015-07-13 23:53:38 +00:00
|
|
|
}
|
|
|
|
|
2016-08-04 00:42:06 +00:00
|
|
|
virtual Status DeleteFile(const std::string& fname) override {
|
|
|
|
delete_count_.fetch_add(1);
|
|
|
|
return target()->DeleteFile(fname);
|
|
|
|
}
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
Random rnd_;
|
|
|
|
port::Mutex rnd_mutex_; // Lock to pretect rnd_
|
|
|
|
|
|
|
|
// sstable Sync() calls are blocked while this pointer is non-nullptr.
|
|
|
|
std::atomic<bool> delay_sstable_sync_;
|
|
|
|
|
|
|
|
// Drop writes on the floor while this pointer is non-nullptr.
|
|
|
|
std::atomic<bool> drop_writes_;
|
|
|
|
|
|
|
|
// Simulate no-space errors while this pointer is non-nullptr.
|
|
|
|
std::atomic<bool> no_space_;
|
|
|
|
|
|
|
|
// Simulate non-writable file system while this pointer is non-nullptr
|
|
|
|
std::atomic<bool> non_writable_;
|
|
|
|
|
|
|
|
// Force sync of manifest files to fail while this pointer is non-nullptr
|
|
|
|
std::atomic<bool> manifest_sync_error_;
|
|
|
|
|
|
|
|
// Force write to manifest files to fail while this pointer is non-nullptr
|
|
|
|
std::atomic<bool> manifest_write_error_;
|
|
|
|
|
|
|
|
// Force write to log files to fail while this pointer is non-nullptr
|
|
|
|
std::atomic<bool> log_write_error_;
|
|
|
|
|
|
|
|
// Slow down every log write, in micro-seconds.
|
|
|
|
std::atomic<int> log_write_slowdown_;
|
|
|
|
|
2016-08-04 00:42:06 +00:00
|
|
|
// Number of WAL files that are still open for write.
|
|
|
|
std::atomic<int> num_open_wal_file_;
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
bool count_random_reads_;
|
|
|
|
anon::AtomicCounter random_read_counter_;
|
2016-05-09 18:52:28 +00:00
|
|
|
std::atomic<size_t> random_read_bytes_counter_;
|
2015-08-04 20:48:16 +00:00
|
|
|
std::atomic<int> random_file_open_counter_;
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
bool count_sequential_reads_;
|
|
|
|
anon::AtomicCounter sequential_read_counter_;
|
|
|
|
|
|
|
|
anon::AtomicCounter sleep_counter_;
|
|
|
|
|
|
|
|
std::atomic<int64_t> bytes_written_;
|
|
|
|
|
|
|
|
std::atomic<int> sync_counter_;
|
|
|
|
|
|
|
|
std::atomic<uint32_t> non_writeable_rate_;
|
|
|
|
|
|
|
|
std::atomic<uint32_t> new_writable_count_;
|
|
|
|
|
|
|
|
std::atomic<uint32_t> non_writable_count_;
|
|
|
|
|
|
|
|
std::function<void()>* table_write_callback_;
|
|
|
|
|
|
|
|
std::atomic<int64_t> addon_time_;
|
2015-11-17 19:06:15 +00:00
|
|
|
|
2016-08-04 00:42:06 +00:00
|
|
|
std::atomic<int> delete_count_;
|
|
|
|
|
move dump stats to a separate thread (#4382)
Summary:
Currently statistics are supposed to be dumped to info log at intervals of `options.stats_dump_period_sec`. However the implementation choice was to bind it with compaction thread, meaning if the database has been serving very light traffic, the stats may not get dumped at all.
We decided to separate stats dumping into a new timed thread using `TimerQueue`, which is already used in blob_db. This will allow us schedule new timed tasks with more deterministic behavior.
Tested with db_bench using `--stats_dump_period_sec=20` in command line:
> LOG:2018/09/17-14:07:45.575025 7fe99fbfe700 [WARN] [db/db_impl.cc:605] ------- DUMPING STATS -------
LOG:2018/09/17-14:08:05.643286 7fe99fbfe700 [WARN] [db/db_impl.cc:605] ------- DUMPING STATS -------
LOG:2018/09/17-14:08:25.691325 7fe99fbfe700 [WARN] [db/db_impl.cc:605] ------- DUMPING STATS -------
LOG:2018/09/17-14:08:45.740989 7fe99fbfe700 [WARN] [db/db_impl.cc:605] ------- DUMPING STATS -------
LOG content:
> 2018/09/17-14:07:45.575025 7fe99fbfe700 [WARN] [db/db_impl.cc:605] ------- DUMPING STATS -------
2018/09/17-14:07:45.575080 7fe99fbfe700 [WARN] [db/db_impl.cc:606]
** DB Stats **
Uptime(secs): 20.0 total, 20.0 interval
Cumulative writes: 4447K writes, 4447K keys, 4447K commit groups, 1.0 writes per commit group, ingest: 5.57 GB, 285.01 MB/s
Cumulative WAL: 4447K writes, 0 syncs, 4447638.00 writes per sync, written: 5.57 GB, 285.01 MB/s
Cumulative stall: 00:00:0.012 H:M:S, 0.1 percent
Interval writes: 4447K writes, 4447K keys, 4447K commit groups, 1.0 writes per commit group, ingest: 5700.71 MB, 285.01 MB/s
Interval WAL: 4447K writes, 0 syncs, 4447638.00 writes per sync, written: 5.57 MB, 285.01 MB/s
Interval stall: 00:00:0.012 H:M:S, 0.1 percent
** Compaction Stats [default] **
Level Files Size Score Read(GB) Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4382
Differential Revision: D9933051
Pulled By: miasantreble
fbshipit-source-id: 6d12bb1e4977674eea4bf2d2ac6d486b814bb2fa
2018-10-09 05:52:58 +00:00
|
|
|
std::atomic<bool> time_elapse_only_sleep_;
|
2015-11-17 19:06:15 +00:00
|
|
|
|
2016-11-22 01:56:19 +00:00
|
|
|
bool no_slowdown_;
|
[wal changes 3/3] method in DB to sync WAL without blocking writers
Summary:
Subj. We really need this feature.
Previous diff D40899 has most of the changes to make this possible, this diff just adds the method.
Test Plan: `make check`, the new test fails without this diff; ran with ASAN, TSAN and valgrind.
Reviewers: igor, rven, IslamAbdelRahman, anthony, kradhakrishnan, tnovak, yhchiang, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, maykov, hermanlee4, yoshinorim, tnovak, dhruba
Differential Revision: https://reviews.facebook.net/D40905
2015-08-05 13:06:39 +00:00
|
|
|
|
2015-10-12 22:06:38 +00:00
|
|
|
std::atomic<bool> is_wal_sync_thread_safe_{true};
|
2017-11-17 01:46:43 +00:00
|
|
|
|
2018-09-12 15:45:59 +00:00
|
|
|
std::atomic<size_t> compaction_readahead_size_{};
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
|
2016-04-18 17:47:10 +00:00
|
|
|
#ifndef ROCKSDB_LITE
|
2016-04-18 16:42:50 +00:00
|
|
|
class OnFileDeletionListener : public EventListener {
|
|
|
|
public:
|
|
|
|
OnFileDeletionListener() : matched_count_(0), expected_file_name_("") {}
|
|
|
|
|
|
|
|
void SetExpectedFileName(const std::string file_name) {
|
|
|
|
expected_file_name_ = file_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerifyMatchedCount(size_t expected_value) {
|
|
|
|
ASSERT_EQ(matched_count_, expected_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnTableFileDeleted(const TableFileDeletionInfo& info) override {
|
|
|
|
if (expected_file_name_ != "") {
|
|
|
|
ASSERT_EQ(expected_file_name_, info.file_path);
|
|
|
|
expected_file_name_ = "";
|
|
|
|
matched_count_++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t matched_count_;
|
|
|
|
std::string expected_file_name_;
|
|
|
|
};
|
2016-04-18 17:47:10 +00:00
|
|
|
#endif
|
2016-04-18 16:42:50 +00:00
|
|
|
|
2017-05-26 19:05:19 +00:00
|
|
|
// A test merge operator mimics put but also fails if one of merge operands is
|
|
|
|
// "corrupted".
|
|
|
|
class TestPutOperator : public MergeOperator {
|
|
|
|
public:
|
|
|
|
virtual bool FullMergeV2(const MergeOperationInput& merge_in,
|
|
|
|
MergeOperationOutput* merge_out) const override {
|
|
|
|
if (merge_in.existing_value != nullptr &&
|
|
|
|
*(merge_in.existing_value) == "corrupted") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (auto value : merge_in.operand_list) {
|
|
|
|
if (value == "corrupted") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
merge_out->existing_operand = merge_in.operand_list.back();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char* Name() const override { return "TestPutOperator"; }
|
|
|
|
};
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
class DBTestBase : public testing::Test {
|
2017-05-31 17:45:47 +00:00
|
|
|
public:
|
2015-07-13 23:53:38 +00:00
|
|
|
// Sequence of option configurations to try
|
2017-05-31 17:45:47 +00:00
|
|
|
enum OptionConfig : int {
|
2015-07-13 23:53:38 +00:00
|
|
|
kDefault = 0,
|
|
|
|
kBlockBasedTableWithPrefixHashIndex = 1,
|
|
|
|
kBlockBasedTableWithWholeKeyHashIndex = 2,
|
|
|
|
kPlainTableFirstBytePrefix = 3,
|
|
|
|
kPlainTableCappedPrefix = 4,
|
2015-09-16 23:57:43 +00:00
|
|
|
kPlainTableCappedPrefixNonMmap = 5,
|
|
|
|
kPlainTableAllBytesPrefix = 6,
|
|
|
|
kVectorRep = 7,
|
|
|
|
kHashLinkList = 8,
|
|
|
|
kHashCuckoo = 9,
|
|
|
|
kMergePut = 10,
|
|
|
|
kFilter = 11,
|
|
|
|
kFullFilterWithNewTableReaderForCompactions = 12,
|
|
|
|
kUncompressed = 13,
|
|
|
|
kNumLevel_3 = 14,
|
|
|
|
kDBLogDir = 15,
|
|
|
|
kWalDirAndMmapReads = 16,
|
|
|
|
kManifestFileSize = 17,
|
|
|
|
kPerfOptions = 18,
|
2016-06-08 00:25:06 +00:00
|
|
|
kHashSkipList = 19,
|
|
|
|
kUniversalCompaction = 20,
|
|
|
|
kUniversalCompactionMultiLevel = 21,
|
|
|
|
kCompressedBlockCache = 22,
|
|
|
|
kInfiniteMaxOpenFiles = 23,
|
|
|
|
kxxHashChecksum = 24,
|
|
|
|
kFIFOCompaction = 25,
|
|
|
|
kOptimizeFiltersForHits = 26,
|
|
|
|
kRowCache = 27,
|
|
|
|
kRecycleLogFiles = 28,
|
|
|
|
kConcurrentSkipList = 29,
|
2017-05-31 17:45:47 +00:00
|
|
|
kPipelinedWrite = 30,
|
2017-06-24 21:06:43 +00:00
|
|
|
kConcurrentWALWrites = 31,
|
2018-06-01 02:16:11 +00:00
|
|
|
kDirectIO,
|
|
|
|
kLevelSubcompactions,
|
|
|
|
kBlockBasedTableWithIndexRestartInterval,
|
|
|
|
kBlockBasedTableWithPartitionedIndex,
|
2018-08-09 23:49:45 +00:00
|
|
|
kBlockBasedTableWithPartitionedIndexFormat4,
|
2018-06-01 02:16:11 +00:00
|
|
|
kPartitionedFilterWithNewTableReaderForCompactions,
|
2018-07-13 18:08:57 +00:00
|
|
|
kUniversalSubcompactions,
|
2018-11-01 22:39:40 +00:00
|
|
|
kxxHash64Checksum,
|
2018-06-05 02:59:44 +00:00
|
|
|
// This must be the last line
|
2018-06-01 02:16:11 +00:00
|
|
|
kEnd,
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
std::string dbname_;
|
|
|
|
std::string alternative_wal_dir_;
|
2015-07-22 00:22:49 +00:00
|
|
|
std::string alternative_db_log_dir_;
|
2015-07-13 23:53:38 +00:00
|
|
|
MockEnv* mem_env_;
|
2017-06-26 23:52:06 +00:00
|
|
|
Env* encrypted_env_;
|
2015-07-13 23:53:38 +00:00
|
|
|
SpecialEnv* env_;
|
|
|
|
DB* db_;
|
|
|
|
std::vector<ColumnFamilyHandle*> handles_;
|
|
|
|
|
2017-05-31 17:45:47 +00:00
|
|
|
int option_config_;
|
2015-07-13 23:53:38 +00:00
|
|
|
Options last_options_;
|
|
|
|
|
|
|
|
// Skip some options, as they may not be applicable to a specific test.
|
|
|
|
// To add more skip constants, use values 4, 8, 16, etc.
|
|
|
|
enum OptionSkip {
|
|
|
|
kNoSkip = 0,
|
|
|
|
kSkipDeletesFilterFirst = 1,
|
|
|
|
kSkipUniversalCompaction = 2,
|
|
|
|
kSkipMergePut = 4,
|
|
|
|
kSkipPlainTable = 8,
|
|
|
|
kSkipHashIndex = 16,
|
|
|
|
kSkipNoSeekToLast = 32,
|
|
|
|
kSkipHashCuckoo = 64,
|
|
|
|
kSkipFIFOCompaction = 128,
|
|
|
|
kSkipMmapReads = 256,
|
|
|
|
};
|
|
|
|
|
2018-07-14 05:40:23 +00:00
|
|
|
const int kRangeDelSkipConfigs =
|
|
|
|
// Plain tables do not support range deletions.
|
|
|
|
kSkipPlainTable |
|
|
|
|
// MmapReads disables the iterator pinning that RangeDelAggregator
|
|
|
|
// requires.
|
|
|
|
kSkipMmapReads;
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
explicit DBTestBase(const std::string path);
|
|
|
|
|
|
|
|
~DBTestBase();
|
|
|
|
|
2015-07-14 00:41:41 +00:00
|
|
|
static std::string RandomString(Random* rnd, int len) {
|
|
|
|
std::string r;
|
|
|
|
test::RandomString(rnd, len, &r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string Key(int i) {
|
|
|
|
char buf[100];
|
|
|
|
snprintf(buf, sizeof(buf), "key%06d", i);
|
|
|
|
return std::string(buf);
|
|
|
|
}
|
|
|
|
|
2016-01-22 19:02:43 +00:00
|
|
|
static bool ShouldSkipOptions(int option_config, int skip_mask = kNoSkip);
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
// Switch to a fresh database with the next option configuration to
|
|
|
|
// test. Return false if there are no more configurations to test.
|
|
|
|
bool ChangeOptions(int skip_mask = kNoSkip);
|
|
|
|
|
2017-03-01 01:32:58 +00:00
|
|
|
// Switch between different compaction styles.
|
2015-07-13 23:53:38 +00:00
|
|
|
bool ChangeCompactOptions();
|
|
|
|
|
2017-03-01 01:32:58 +00:00
|
|
|
// Switch between different WAL-realted options.
|
|
|
|
bool ChangeWalOptions();
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
// Switch between different filter policy
|
|
|
|
// Jump from kDefault to kFilter to kFullFilter
|
|
|
|
bool ChangeFilterOptions();
|
|
|
|
|
2018-11-01 23:21:30 +00:00
|
|
|
// Switch between different DB options for file ingestion tests.
|
|
|
|
bool ChangeOptionsForFileIngestionTest();
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
// Return the current option configuration.
|
2017-05-31 17:45:47 +00:00
|
|
|
Options CurrentOptions(const anon::OptionsOverride& options_override =
|
|
|
|
anon::OptionsOverride()) const;
|
|
|
|
|
|
|
|
Options CurrentOptions(const Options& default_options,
|
|
|
|
const anon::OptionsOverride& options_override =
|
|
|
|
anon::OptionsOverride()) const;
|
|
|
|
|
|
|
|
static Options GetDefaultOptions();
|
2015-07-13 23:53:38 +00:00
|
|
|
|
2017-05-31 17:45:47 +00:00
|
|
|
Options GetOptions(int option_config,
|
|
|
|
const Options& default_options = GetDefaultOptions(),
|
|
|
|
const anon::OptionsOverride& options_override =
|
|
|
|
anon::OptionsOverride()) const;
|
2015-07-13 23:53:38 +00:00
|
|
|
|
2015-10-12 22:06:38 +00:00
|
|
|
DBImpl* dbfull() { return reinterpret_cast<DBImpl*>(db_); }
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
void CreateColumnFamilies(const std::vector<std::string>& cfs,
|
|
|
|
const Options& options);
|
|
|
|
|
|
|
|
void CreateAndReopenWithCF(const std::vector<std::string>& cfs,
|
|
|
|
const Options& options);
|
|
|
|
|
|
|
|
void ReopenWithColumnFamilies(const std::vector<std::string>& cfs,
|
|
|
|
const std::vector<Options>& options);
|
|
|
|
|
|
|
|
void ReopenWithColumnFamilies(const std::vector<std::string>& cfs,
|
|
|
|
const Options& options);
|
|
|
|
|
2015-10-12 22:06:38 +00:00
|
|
|
Status TryReopenWithColumnFamilies(const std::vector<std::string>& cfs,
|
|
|
|
const std::vector<Options>& options);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
Status TryReopenWithColumnFamilies(const std::vector<std::string>& cfs,
|
|
|
|
const Options& options);
|
|
|
|
|
|
|
|
void Reopen(const Options& options);
|
|
|
|
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
void DestroyAndReopen(const Options& options);
|
|
|
|
|
2018-04-06 02:49:06 +00:00
|
|
|
void Destroy(const Options& options, bool delete_cf_paths = false);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
Status ReadOnlyReopen(const Options& options);
|
|
|
|
|
|
|
|
Status TryReopen(const Options& options);
|
|
|
|
|
2016-12-22 20:51:29 +00:00
|
|
|
bool IsDirectIOSupported();
|
|
|
|
|
2017-06-26 23:52:06 +00:00
|
|
|
bool IsMemoryMappedAccessSupported() const;
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Flush(int cf = 0);
|
|
|
|
|
2018-10-26 22:06:44 +00:00
|
|
|
Status Flush(const std::vector<int>& cf_ids);
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Put(const Slice& k, const Slice& v, WriteOptions wo = WriteOptions());
|
|
|
|
|
|
|
|
Status Put(int cf, const Slice& k, const Slice& v,
|
|
|
|
WriteOptions wo = WriteOptions());
|
|
|
|
|
2016-12-16 19:00:03 +00:00
|
|
|
Status Merge(const Slice& k, const Slice& v,
|
|
|
|
WriteOptions wo = WriteOptions());
|
|
|
|
|
|
|
|
Status Merge(int cf, const Slice& k, const Slice& v,
|
|
|
|
WriteOptions wo = WriteOptions());
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
Status Delete(const std::string& k);
|
|
|
|
|
|
|
|
Status Delete(int cf, const std::string& k);
|
|
|
|
|
Support for SingleDelete()
Summary:
This patch fixes #7460559. It introduces SingleDelete as a new database
operation. This operation can be used to delete keys that were never
overwritten (no put following another put of the same key). If an overwritten
key is single deleted the behavior is undefined. Single deletion of a
non-existent key has no effect but multiple consecutive single deletions are
not allowed (see limitations).
In contrast to the conventional Delete() operation, the deletion entry is
removed along with the value when the two are lined up in a compaction. Note:
The semantics are similar to @igor's prototype that allowed to have this
behavior on the granularity of a column family (
https://reviews.facebook.net/D42093 ). This new patch, however, is more
aggressive when it comes to removing tombstones: It removes the SingleDelete
together with the value whenever there is no snapshot between them while the
older patch only did this when the sequence number of the deletion was older
than the earliest snapshot.
Most of the complex additions are in the Compaction Iterator, all other changes
should be relatively straightforward. The patch also includes basic support for
single deletions in db_stress and db_bench.
Limitations:
- Not compatible with cuckoo hash tables
- Single deletions cannot be used in combination with merges and normal
deletions on the same key (other keys are not affected by this)
- Consecutive single deletions are currently not allowed (and older version of
this patch supported this so it could be resurrected if needed)
Test Plan: make all check
Reviewers: yhchiang, sdong, rven, anthony, yoshinorim, igor
Reviewed By: igor
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D43179
2015-09-17 18:42:56 +00:00
|
|
|
Status SingleDelete(const std::string& k);
|
|
|
|
|
|
|
|
Status SingleDelete(int cf, const std::string& k);
|
|
|
|
|
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 SetPreserveDeletesSequenceNumber(SequenceNumber sn);
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
std::string Get(const std::string& k, const Snapshot* snapshot = nullptr);
|
|
|
|
|
|
|
|
std::string Get(int cf, const std::string& k,
|
|
|
|
const Snapshot* snapshot = nullptr);
|
|
|
|
|
2017-07-17 21:53:15 +00:00
|
|
|
Status Get(const std::string& k, PinnableSlice* v);
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
uint64_t GetNumSnapshots();
|
|
|
|
|
|
|
|
uint64_t GetTimeOldestSnapshots();
|
|
|
|
|
|
|
|
// Return a string that contains all key,value pairs in order,
|
|
|
|
// formatted like "(k1->v1)(k2->v2)".
|
|
|
|
std::string Contents(int cf = 0);
|
|
|
|
|
|
|
|
std::string AllEntriesFor(const Slice& user_key, int cf = 0);
|
|
|
|
|
2015-10-14 00:33:23 +00:00
|
|
|
#ifndef ROCKSDB_LITE
|
2015-07-13 23:53:38 +00:00
|
|
|
int NumSortedRuns(int cf = 0);
|
|
|
|
|
|
|
|
uint64_t TotalSize(int cf = 0);
|
|
|
|
|
|
|
|
uint64_t SizeAtLevel(int level);
|
|
|
|
|
2015-11-15 18:49:14 +00:00
|
|
|
size_t TotalLiveFiles(int cf = 0);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
2015-10-14 00:33:23 +00:00
|
|
|
size_t CountLiveFiles();
|
|
|
|
|
|
|
|
int NumTableFilesAtLevel(int level, int cf = 0);
|
|
|
|
|
2016-04-21 01:46:54 +00:00
|
|
|
double CompressionRatioAtLevel(int level, int cf = 0);
|
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
int TotalTableFiles(int cf = 0, int levels = -1);
|
2018-01-17 01:26:29 +00:00
|
|
|
#endif // ROCKSDB_LITE
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
// Return spread of files per level
|
|
|
|
std::string FilesPerLevel(int cf = 0);
|
|
|
|
|
|
|
|
size_t CountFiles();
|
|
|
|
|
|
|
|
uint64_t Size(const Slice& start, const Slice& limit, int cf = 0);
|
|
|
|
|
|
|
|
void Compact(int cf, const Slice& start, const Slice& limit,
|
|
|
|
uint32_t target_path_id);
|
|
|
|
|
|
|
|
void Compact(int cf, const Slice& start, const Slice& limit);
|
|
|
|
|
|
|
|
void Compact(const Slice& start, const Slice& limit);
|
|
|
|
|
|
|
|
// Do n memtable compactions, each of which produces an sstable
|
|
|
|
// covering the range [small,large].
|
|
|
|
void MakeTables(int n, const std::string& small, const std::string& large,
|
|
|
|
int cf = 0);
|
|
|
|
|
|
|
|
// Prevent pushing of new sstables into deeper levels by adding
|
|
|
|
// tables that cover a specified range to all levels.
|
|
|
|
void FillLevels(const std::string& smallest, const std::string& largest,
|
|
|
|
int cf);
|
|
|
|
|
2015-07-17 19:02:52 +00:00
|
|
|
void MoveFilesToLevel(int level, int cf = 0);
|
|
|
|
|
2018-01-17 01:26:29 +00:00
|
|
|
#ifndef ROCKSDB_LITE
|
2015-07-13 23:53:38 +00:00
|
|
|
void DumpFileCounts(const char* label);
|
2018-01-17 01:26:29 +00:00
|
|
|
#endif // ROCKSDB_LITE
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
std::string DumpSSTableList();
|
|
|
|
|
2018-04-06 02:49:06 +00:00
|
|
|
static void GetSstFiles(Env* env, std::string path,
|
|
|
|
std::vector<std::string>* files);
|
2015-10-07 00:46:22 +00:00
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
int GetSstFileCount(std::string path);
|
|
|
|
|
|
|
|
// this will generate non-overlapping files since it keeps increasing key_idx
|
|
|
|
void GenerateNewFile(Random* rnd, int* key_idx, bool nowait = false);
|
|
|
|
|
2015-08-26 21:19:31 +00:00
|
|
|
void GenerateNewFile(int fd, Random* rnd, int* key_idx, bool nowait = false);
|
|
|
|
|
2015-11-30 19:41:53 +00:00
|
|
|
static const int kNumKeysByGenerateNewRandomFile;
|
2015-12-04 03:05:13 +00:00
|
|
|
static const int KNumKeysByGenerateNewFile = 100;
|
2015-11-30 19:41:53 +00:00
|
|
|
|
2015-07-13 23:53:38 +00:00
|
|
|
void GenerateNewRandomFile(Random* rnd, bool nowait = false);
|
|
|
|
|
|
|
|
std::string IterStatus(Iterator* iter);
|
|
|
|
|
|
|
|
Options OptionsForLogIterTest();
|
|
|
|
|
|
|
|
std::string DummyString(size_t len, char c = 'a');
|
|
|
|
|
|
|
|
void VerifyIterLast(std::string expected_key, int cf = 0);
|
|
|
|
|
|
|
|
// Used to test InplaceUpdate
|
|
|
|
|
|
|
|
// If previous value is nullptr or delta is > than previous value,
|
|
|
|
// sets newValue with delta
|
|
|
|
// If previous value is not empty,
|
|
|
|
// updates previous value with 'b' string of previous value size - 1.
|
2015-10-12 22:06:38 +00:00
|
|
|
static UpdateStatus updateInPlaceSmallerSize(char* prevValue,
|
|
|
|
uint32_t* prevSize, Slice delta,
|
|
|
|
std::string* newValue);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
2015-10-12 22:06:38 +00:00
|
|
|
static UpdateStatus updateInPlaceSmallerVarintSize(char* prevValue,
|
|
|
|
uint32_t* prevSize,
|
|
|
|
Slice delta,
|
|
|
|
std::string* newValue);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
2015-10-12 22:06:38 +00:00
|
|
|
static UpdateStatus updateInPlaceLargerSize(char* prevValue,
|
|
|
|
uint32_t* prevSize, Slice delta,
|
|
|
|
std::string* newValue);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
2015-10-12 22:06:38 +00:00
|
|
|
static UpdateStatus updateInPlaceNoAction(char* prevValue, uint32_t* prevSize,
|
|
|
|
Slice delta, std::string* newValue);
|
2015-07-13 23:53:38 +00:00
|
|
|
|
|
|
|
// Utility method to test InplaceUpdate
|
|
|
|
void validateNumberOfEntries(int numValues, int cf = 0);
|
|
|
|
|
|
|
|
void CopyFile(const std::string& source, const std::string& destination,
|
|
|
|
uint64_t size = 0);
|
2016-01-29 02:35:01 +00:00
|
|
|
|
2016-02-17 23:20:23 +00:00
|
|
|
std::unordered_map<std::string, uint64_t> GetAllSSTFiles(
|
|
|
|
uint64_t* total_size = nullptr);
|
2016-04-18 16:42:50 +00:00
|
|
|
|
|
|
|
std::vector<std::uint64_t> ListTableFiles(Env* env, const std::string& path);
|
|
|
|
|
2017-01-03 23:42:54 +00:00
|
|
|
void VerifyDBFromMap(
|
|
|
|
std::map<std::string, std::string> true_data,
|
|
|
|
size_t* total_reads_res = nullptr, bool tailing_iter = false,
|
|
|
|
std::map<std::string, Status> status = std::map<std::string, Status>());
|
2016-12-16 19:00:03 +00:00
|
|
|
|
|
|
|
void VerifyDBInternal(
|
|
|
|
std::vector<std::pair<std::string, std::string>> true_data);
|
Introduce FullMergeV2 (eliminate memcpy from merge operators)
Summary:
This diff update the code to pin the merge operator operands while the merge operation is done, so that we can eliminate the memcpy cost, to do that we need a new public API for FullMerge that replace the std::deque<std::string> with std::vector<Slice>
This diff is stacked on top of D56493 and D56511
In this diff we
- Update FullMergeV2 arguments to be encapsulated in MergeOperationInput and MergeOperationOutput which will make it easier to add new arguments in the future
- Replace std::deque<std::string> with std::vector<Slice> to pass operands
- Replace MergeContext std::deque with std::vector (based on a simple benchmark I ran https://gist.github.com/IslamAbdelRahman/78fc86c9ab9f52b1df791e58943fb187)
- Allow FullMergeV2 output to be an existing operand
```
[Everything in Memtable | 10K operands | 10 KB each | 1 operand per key]
DEBUG_LEVEL=0 make db_bench -j64 && ./db_bench --benchmarks="mergerandom,readseq,readseq,readseq,readseq,readseq" --merge_operator="max" --merge_keys=10000 --num=10000 --disable_auto_compactions --value_size=10240 --write_buffer_size=1000000000
[FullMergeV2]
readseq : 0.607 micros/op 1648235 ops/sec; 16121.2 MB/s
readseq : 0.478 micros/op 2091546 ops/sec; 20457.2 MB/s
readseq : 0.252 micros/op 3972081 ops/sec; 38850.5 MB/s
readseq : 0.237 micros/op 4218328 ops/sec; 41259.0 MB/s
readseq : 0.247 micros/op 4043927 ops/sec; 39553.2 MB/s
[master]
readseq : 3.935 micros/op 254140 ops/sec; 2485.7 MB/s
readseq : 3.722 micros/op 268657 ops/sec; 2627.7 MB/s
readseq : 3.149 micros/op 317605 ops/sec; 3106.5 MB/s
readseq : 3.125 micros/op 320024 ops/sec; 3130.1 MB/s
readseq : 4.075 micros/op 245374 ops/sec; 2400.0 MB/s
```
```
[Everything in Memtable | 10K operands | 10 KB each | 10 operand per key]
DEBUG_LEVEL=0 make db_bench -j64 && ./db_bench --benchmarks="mergerandom,readseq,readseq,readseq,readseq,readseq" --merge_operator="max" --merge_keys=1000 --num=10000 --disable_auto_compactions --value_size=10240 --write_buffer_size=1000000000
[FullMergeV2]
readseq : 3.472 micros/op 288018 ops/sec; 2817.1 MB/s
readseq : 2.304 micros/op 434027 ops/sec; 4245.2 MB/s
readseq : 1.163 micros/op 859845 ops/sec; 8410.0 MB/s
readseq : 1.192 micros/op 838926 ops/sec; 8205.4 MB/s
readseq : 1.250 micros/op 800000 ops/sec; 7824.7 MB/s
[master]
readseq : 24.025 micros/op 41623 ops/sec; 407.1 MB/s
readseq : 18.489 micros/op 54086 ops/sec; 529.0 MB/s
readseq : 18.693 micros/op 53495 ops/sec; 523.2 MB/s
readseq : 23.621 micros/op 42335 ops/sec; 414.1 MB/s
readseq : 18.775 micros/op 53262 ops/sec; 521.0 MB/s
```
```
[Everything in Block cache | 10K operands | 10 KB each | 1 operand per key]
[FullMergeV2]
$ DEBUG_LEVEL=0 make db_bench -j64 && ./db_bench --benchmarks="readseq,readseq,readseq,readseq,readseq" --merge_operator="max" --num=100000 --db="/dev/shm/merge-random-10K-10KB" --cache_size=1000000000 --use_existing_db --disable_auto_compactions
readseq : 14.741 micros/op 67837 ops/sec; 663.5 MB/s
readseq : 1.029 micros/op 971446 ops/sec; 9501.6 MB/s
readseq : 0.974 micros/op 1026229 ops/sec; 10037.4 MB/s
readseq : 0.965 micros/op 1036080 ops/sec; 10133.8 MB/s
readseq : 0.943 micros/op 1060657 ops/sec; 10374.2 MB/s
[master]
readseq : 16.735 micros/op 59755 ops/sec; 584.5 MB/s
readseq : 3.029 micros/op 330151 ops/sec; 3229.2 MB/s
readseq : 3.136 micros/op 318883 ops/sec; 3119.0 MB/s
readseq : 3.065 micros/op 326245 ops/sec; 3191.0 MB/s
readseq : 3.014 micros/op 331813 ops/sec; 3245.4 MB/s
```
```
[Everything in Block cache | 10K operands | 10 KB each | 10 operand per key]
DEBUG_LEVEL=0 make db_bench -j64 && ./db_bench --benchmarks="readseq,readseq,readseq,readseq,readseq" --merge_operator="max" --num=100000 --db="/dev/shm/merge-random-10-operands-10K-10KB" --cache_size=1000000000 --use_existing_db --disable_auto_compactions
[FullMergeV2]
readseq : 24.325 micros/op 41109 ops/sec; 402.1 MB/s
readseq : 1.470 micros/op 680272 ops/sec; 6653.7 MB/s
readseq : 1.231 micros/op 812347 ops/sec; 7945.5 MB/s
readseq : 1.091 micros/op 916590 ops/sec; 8965.1 MB/s
readseq : 1.109 micros/op 901713 ops/sec; 8819.6 MB/s
[master]
readseq : 27.257 micros/op 36687 ops/sec; 358.8 MB/s
readseq : 4.443 micros/op 225073 ops/sec; 2201.4 MB/s
readseq : 5.830 micros/op 171526 ops/sec; 1677.7 MB/s
readseq : 4.173 micros/op 239635 ops/sec; 2343.8 MB/s
readseq : 4.150 micros/op 240963 ops/sec; 2356.8 MB/s
```
Test Plan: COMPILE_WITH_ASAN=1 make check -j64
Reviewers: yhchiang, andrewkr, sdong
Reviewed By: sdong
Subscribers: lovro, andrewkr, dhruba
Differential Revision: https://reviews.facebook.net/D57075
2016-07-20 16:49:03 +00:00
|
|
|
|
2016-04-18 16:42:50 +00:00
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
uint64_t GetNumberOfSstFilesForColumnFamily(DB* db,
|
|
|
|
std::string column_family_name);
|
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
|
|
|
|
uint64_t TestGetTickerCount(const Options& options, Tickers ticker_type) {
|
|
|
|
return options.statistics->getTickerCount(ticker_type);
|
|
|
|
}
|
2015-07-13 23:53:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace rocksdb
|