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).
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
//
|
2017-02-18 20:54:49 +01:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
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
|
|
|
#include "env/composite_env_wrapper.h"
|
2019-09-16 19:31:27 +02:00
|
|
|
#include "file/random_access_file_reader.h"
|
|
|
|
#include "file/readahead_raf.h"
|
|
|
|
#include "file/sequence_file_reader.h"
|
|
|
|
#include "file/writable_file_writer.h"
|
2019-05-30 20:21:38 +02:00
|
|
|
#include "test_util/testharness.h"
|
|
|
|
#include "test_util/testutil.h"
|
2019-05-31 02:39:43 +02:00
|
|
|
#include "util/random.h"
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
|
|
|
|
class WritableFileWriterTest : public testing::Test {};
|
|
|
|
|
|
|
|
const uint32_t kMb = 1 << 20;
|
|
|
|
|
|
|
|
TEST_F(WritableFileWriterTest, RangeSync) {
|
|
|
|
class FakeWF : public WritableFile {
|
|
|
|
public:
|
|
|
|
explicit FakeWF() : size_(0), last_synced_(0) {}
|
2019-02-14 22:52:47 +01:00
|
|
|
~FakeWF() override {}
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
|
|
|
|
Status Append(const Slice& data) override {
|
|
|
|
size_ += data.size();
|
|
|
|
return Status::OK();
|
|
|
|
}
|
2019-02-14 22:52:47 +01:00
|
|
|
Status Truncate(uint64_t /*size*/) override { return Status::OK(); }
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
Status Close() override {
|
|
|
|
EXPECT_GE(size_, last_synced_ + kMb);
|
|
|
|
EXPECT_LT(size_, last_synced_ + 2 * kMb);
|
|
|
|
// Make sure random writes generated enough writes.
|
|
|
|
EXPECT_GT(size_, 10 * kMb);
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
Status Flush() override { return Status::OK(); }
|
|
|
|
Status Sync() override { return Status::OK(); }
|
|
|
|
Status Fsync() override { return Status::OK(); }
|
2018-03-05 22:08:17 +01:00
|
|
|
void SetIOPriority(Env::IOPriority /*pri*/) override {}
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
uint64_t GetFileSize() override { return size_; }
|
2018-03-05 22:08:17 +01:00
|
|
|
void GetPreallocationStatus(size_t* /*block_size*/,
|
|
|
|
size_t* /*last_allocated_block*/) override {}
|
|
|
|
size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const override {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Status InvalidateCache(size_t /*offset*/, size_t /*length*/) override {
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-03-05 22:08:17 +01:00
|
|
|
Status Allocate(uint64_t /*offset*/, uint64_t /*len*/) override {
|
|
|
|
return Status::OK();
|
|
|
|
}
|
2015-11-11 02:03:42 +01:00
|
|
|
Status RangeSync(uint64_t offset, uint64_t nbytes) override {
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
EXPECT_EQ(offset % 4096, 0u);
|
|
|
|
EXPECT_EQ(nbytes % 4096, 0u);
|
|
|
|
|
|
|
|
EXPECT_EQ(offset, last_synced_);
|
|
|
|
last_synced_ = offset + nbytes;
|
|
|
|
EXPECT_GE(size_, last_synced_ + kMb);
|
|
|
|
if (size_ > 2 * kMb) {
|
|
|
|
EXPECT_LT(size_, last_synced_ + 2 * kMb);
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t size_;
|
|
|
|
uint64_t last_synced_;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnvOptions env_options;
|
|
|
|
env_options.bytes_per_sync = kMb;
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<FakeWF> wf(new FakeWF);
|
|
|
|
std::unique_ptr<WritableFileWriter> writer(
|
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
|
|
|
new WritableFileWriter(NewLegacyWritableFileWrapper(std::move(wf)),
|
|
|
|
"" /* don't care */, env_options));
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
Random r(301);
|
2020-09-29 01:03:43 +02:00
|
|
|
Status s;
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
std::unique_ptr<char[]> large_buf(new char[10 * kMb]);
|
|
|
|
for (int i = 0; i < 1000; i++) {
|
|
|
|
int skew_limit = (i < 700) ? 10 : 15;
|
|
|
|
uint32_t num = r.Skewed(skew_limit) * 100 + r.Uniform(100);
|
2020-09-29 01:03:43 +02:00
|
|
|
s = writer->Append(Slice(large_buf.get(), num));
|
|
|
|
ASSERT_OK(s);
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
|
|
|
|
// Flush in a chance of 1/10.
|
|
|
|
if (r.Uniform(10) == 0) {
|
2020-09-29 01:03:43 +02:00
|
|
|
s = writer->Flush();
|
|
|
|
ASSERT_OK(s);
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-29 01:03:43 +02:00
|
|
|
s = writer->Close();
|
|
|
|
ASSERT_OK(s);
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
}
|
2015-10-28 05:04:00 +01:00
|
|
|
|
2017-06-13 13:34:51 +02:00
|
|
|
TEST_F(WritableFileWriterTest, IncrementalBuffer) {
|
|
|
|
class FakeWF : public WritableFile {
|
|
|
|
public:
|
|
|
|
explicit FakeWF(std::string* _file_data, bool _use_direct_io,
|
|
|
|
bool _no_flush)
|
|
|
|
: file_data_(_file_data),
|
|
|
|
use_direct_io_(_use_direct_io),
|
|
|
|
no_flush_(_no_flush) {}
|
2019-02-14 22:52:47 +01:00
|
|
|
~FakeWF() override {}
|
2017-06-13 13:34:51 +02:00
|
|
|
|
|
|
|
Status Append(const Slice& data) override {
|
|
|
|
file_data_->append(data.data(), data.size());
|
|
|
|
size_ += data.size();
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
Status PositionedAppend(const Slice& data, uint64_t pos) override {
|
|
|
|
EXPECT_TRUE(pos % 512 == 0);
|
|
|
|
EXPECT_TRUE(data.size() % 512 == 0);
|
|
|
|
file_data_->resize(pos);
|
|
|
|
file_data_->append(data.data(), data.size());
|
|
|
|
size_ += data.size();
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:52:47 +01:00
|
|
|
Status Truncate(uint64_t size) override {
|
2017-06-13 13:34:51 +02:00
|
|
|
file_data_->resize(size);
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
Status Close() override { return Status::OK(); }
|
|
|
|
Status Flush() override { return Status::OK(); }
|
|
|
|
Status Sync() override { return Status::OK(); }
|
|
|
|
Status Fsync() override { return Status::OK(); }
|
2018-03-05 22:08:17 +01:00
|
|
|
void SetIOPriority(Env::IOPriority /*pri*/) override {}
|
2017-06-13 13:34:51 +02:00
|
|
|
uint64_t GetFileSize() override { return size_; }
|
2018-03-05 22:08:17 +01:00
|
|
|
void GetPreallocationStatus(size_t* /*block_size*/,
|
|
|
|
size_t* /*last_allocated_block*/) override {}
|
|
|
|
size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const override {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Status InvalidateCache(size_t /*offset*/, size_t /*length*/) override {
|
2017-06-13 13:34:51 +02:00
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
bool use_direct_io() const override { return use_direct_io_; }
|
|
|
|
|
|
|
|
std::string* file_data_;
|
|
|
|
bool use_direct_io_;
|
|
|
|
bool no_flush_;
|
|
|
|
size_t size_ = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
Random r(301);
|
|
|
|
const int kNumAttempts = 50;
|
|
|
|
for (int attempt = 0; attempt < kNumAttempts; attempt++) {
|
|
|
|
bool no_flush = (attempt % 3 == 0);
|
|
|
|
EnvOptions env_options;
|
|
|
|
env_options.writable_file_max_buffer_size =
|
|
|
|
(attempt < kNumAttempts / 2) ? 512 * 1024 : 700 * 1024;
|
|
|
|
std::string actual;
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<FakeWF> wf(new FakeWF(&actual,
|
2017-07-27 06:02:53 +02:00
|
|
|
#ifndef ROCKSDB_LITE
|
2018-11-09 20:17:34 +01:00
|
|
|
attempt % 2 == 1,
|
2017-07-27 06:02:53 +02:00
|
|
|
#else
|
2018-11-09 20:17:34 +01:00
|
|
|
false,
|
2017-07-27 06:02:53 +02:00
|
|
|
#endif
|
2018-11-09 20:17:34 +01:00
|
|
|
no_flush));
|
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
|
|
|
std::unique_ptr<WritableFileWriter> writer(
|
|
|
|
new WritableFileWriter(NewLegacyWritableFileWrapper(std::move(wf)),
|
|
|
|
"" /* don't care */, env_options));
|
2017-06-13 13:34:51 +02:00
|
|
|
|
|
|
|
std::string target;
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
|
uint32_t num = r.Skewed(16) * 100 + r.Uniform(100);
|
2020-07-09 23:33:42 +02:00
|
|
|
std::string random_string = r.RandomString(num);
|
2020-12-24 01:54:05 +01:00
|
|
|
ASSERT_OK(writer->Append(Slice(random_string.c_str(), num)));
|
2017-06-13 13:34:51 +02:00
|
|
|
target.append(random_string.c_str(), num);
|
|
|
|
|
|
|
|
// In some attempts, flush in a chance of 1/10.
|
|
|
|
if (!no_flush && r.Uniform(10) == 0) {
|
2020-12-24 01:54:05 +01:00
|
|
|
ASSERT_OK(writer->Flush());
|
2017-06-13 13:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
2020-12-24 01:54:05 +01:00
|
|
|
ASSERT_OK(writer->Flush());
|
|
|
|
ASSERT_OK(writer->Close());
|
2017-06-13 13:34:51 +02:00
|
|
|
ASSERT_EQ(target.size(), actual.size());
|
|
|
|
ASSERT_EQ(target, actual);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-16 19:25:06 +01:00
|
|
|
#ifndef ROCKSDB_LITE
|
2015-10-28 05:04:00 +01:00
|
|
|
TEST_F(WritableFileWriterTest, AppendStatusReturn) {
|
|
|
|
class FakeWF : public WritableFile {
|
|
|
|
public:
|
2016-12-22 21:51:29 +01:00
|
|
|
explicit FakeWF() : use_direct_io_(false), io_error_(false) {}
|
2015-10-28 05:04:00 +01:00
|
|
|
|
2019-02-14 22:52:47 +01:00
|
|
|
bool use_direct_io() const override { return use_direct_io_; }
|
2018-03-05 22:08:17 +01:00
|
|
|
Status Append(const Slice& /*data*/) override {
|
2015-10-28 05:04:00 +01:00
|
|
|
if (io_error_) {
|
|
|
|
return Status::IOError("Fake IO error");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
2018-03-05 22:08:17 +01:00
|
|
|
Status PositionedAppend(const Slice& /*data*/, uint64_t) override {
|
2015-10-28 05:04:00 +01:00
|
|
|
if (io_error_) {
|
|
|
|
return Status::IOError("Fake IO error");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
Status Close() override { return Status::OK(); }
|
|
|
|
Status Flush() override { return Status::OK(); }
|
|
|
|
Status Sync() override { return Status::OK(); }
|
2017-01-13 21:01:08 +01:00
|
|
|
void Setuse_direct_io(bool val) { use_direct_io_ = val; }
|
2015-10-28 05:04:00 +01:00
|
|
|
void SetIOError(bool val) { io_error_ = val; }
|
|
|
|
|
|
|
|
protected:
|
2016-12-22 21:51:29 +01:00
|
|
|
bool use_direct_io_;
|
2015-10-28 05:04:00 +01:00
|
|
|
bool io_error_;
|
|
|
|
};
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<FakeWF> wf(new FakeWF());
|
2017-01-13 21:01:08 +01:00
|
|
|
wf->Setuse_direct_io(true);
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<WritableFileWriter> writer(
|
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
|
|
|
new WritableFileWriter(NewLegacyWritableFileWrapper(std::move(wf)),
|
|
|
|
"" /* don't care */, EnvOptions()));
|
2015-10-28 05:04:00 +01:00
|
|
|
|
|
|
|
ASSERT_OK(writer->Append(std::string(2 * kMb, 'a')));
|
|
|
|
|
|
|
|
// Next call to WritableFile::Append() should fail
|
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
|
|
|
LegacyWritableFileWrapper* file =
|
|
|
|
static_cast<LegacyWritableFileWrapper*>(writer->writable_file());
|
|
|
|
static_cast<FakeWF*>(file->target())->SetIOError(true);
|
2015-10-28 05:04:00 +01:00
|
|
|
ASSERT_NOK(writer->Append(std::string(2 * kMb, 'b')));
|
|
|
|
}
|
2017-02-16 19:25:06 +01:00
|
|
|
#endif
|
2015-10-28 05:04:00 +01:00
|
|
|
|
2017-02-18 20:54:49 +01:00
|
|
|
class ReadaheadRandomAccessFileTest
|
|
|
|
: public testing::Test,
|
|
|
|
public testing::WithParamInterface<size_t> {
|
|
|
|
public:
|
|
|
|
static std::vector<size_t> GetReadaheadSizeList() {
|
|
|
|
return {1lu << 12, 1lu << 16};
|
|
|
|
}
|
2019-02-14 22:52:47 +01:00
|
|
|
void SetUp() override {
|
2017-02-18 20:54:49 +01:00
|
|
|
readahead_size_ = GetParam();
|
|
|
|
scratch_.reset(new char[2 * readahead_size_]);
|
|
|
|
ResetSourceStr();
|
|
|
|
}
|
|
|
|
ReadaheadRandomAccessFileTest() : control_contents_() {}
|
|
|
|
std::string Read(uint64_t offset, size_t n) {
|
|
|
|
Slice result;
|
2021-01-05 00:59:52 +01:00
|
|
|
Status s = test_read_holder_->Read(offset, n, IOOptions(), &result,
|
|
|
|
scratch_.get(), nullptr);
|
2020-09-29 01:03:43 +02:00
|
|
|
EXPECT_TRUE(s.ok() || s.IsInvalidArgument());
|
2017-02-18 20:54:49 +01:00
|
|
|
return std::string(result.data(), result.size());
|
|
|
|
}
|
|
|
|
void ResetSourceStr(const std::string& str = "") {
|
2021-01-05 00:59:52 +01:00
|
|
|
std::unique_ptr<FSWritableFile> sink(
|
|
|
|
new test::StringSink(&control_contents_));
|
|
|
|
std::unique_ptr<WritableFileWriter> write_holder(new WritableFileWriter(
|
|
|
|
std::move(sink), "" /* don't care */, FileOptions()));
|
2020-09-29 01:03:43 +02:00
|
|
|
Status s = write_holder->Append(Slice(str));
|
|
|
|
EXPECT_OK(s);
|
|
|
|
s = write_holder->Flush();
|
|
|
|
EXPECT_OK(s);
|
2021-01-05 00:59:52 +01:00
|
|
|
std::unique_ptr<FSRandomAccessFile> read_holder(
|
2017-02-18 20:54:49 +01:00
|
|
|
new test::StringSource(control_contents_));
|
|
|
|
test_read_holder_ =
|
|
|
|
NewReadaheadRandomAccessFile(std::move(read_holder), readahead_size_);
|
|
|
|
}
|
|
|
|
size_t GetReadaheadSize() const { return readahead_size_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t readahead_size_;
|
|
|
|
Slice control_contents_;
|
2021-01-05 00:59:52 +01:00
|
|
|
std::unique_ptr<FSRandomAccessFile> test_read_holder_;
|
2017-02-18 20:54:49 +01:00
|
|
|
std::unique_ptr<char[]> scratch_;
|
|
|
|
};
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadRandomAccessFileTest, EmptySourceStr) {
|
2017-02-18 20:54:49 +01:00
|
|
|
ASSERT_EQ("", Read(0, 1));
|
|
|
|
ASSERT_EQ("", Read(0, 0));
|
|
|
|
ASSERT_EQ("", Read(13, 13));
|
|
|
|
}
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadRandomAccessFileTest, SourceStrLenLessThanReadaheadSize) {
|
2017-02-18 20:54:49 +01:00
|
|
|
std::string str = "abcdefghijklmnopqrs";
|
|
|
|
ResetSourceStr(str);
|
|
|
|
ASSERT_EQ(str.substr(3, 4), Read(3, 4));
|
|
|
|
ASSERT_EQ(str.substr(0, 3), Read(0, 3));
|
|
|
|
ASSERT_EQ(str, Read(0, str.size()));
|
|
|
|
ASSERT_EQ(str.substr(7, std::min(static_cast<int>(str.size()) - 7, 30)),
|
|
|
|
Read(7, 30));
|
|
|
|
ASSERT_EQ("", Read(100, 100));
|
|
|
|
}
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadRandomAccessFileTest, SourceStrLenGreaterThanReadaheadSize) {
|
2017-02-18 20:54:49 +01:00
|
|
|
Random rng(42);
|
|
|
|
for (int k = 0; k < 100; ++k) {
|
|
|
|
size_t strLen = k * GetReadaheadSize() +
|
|
|
|
rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
2020-07-09 23:33:42 +02:00
|
|
|
std::string str = rng.HumanReadableString(static_cast<int>(strLen));
|
2017-02-18 20:54:49 +01:00
|
|
|
ResetSourceStr(str);
|
|
|
|
for (int test = 1; test <= 100; ++test) {
|
|
|
|
size_t offset = rng.Uniform(static_cast<int>(strLen));
|
|
|
|
size_t n = rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
2019-07-17 03:18:07 +02:00
|
|
|
ASSERT_EQ(str.substr(offset, std::min(n, strLen - offset)),
|
2017-02-18 20:54:49 +01:00
|
|
|
Read(offset, n));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadRandomAccessFileTest, ReadExceedsReadaheadSize) {
|
2017-02-18 20:54:49 +01:00
|
|
|
Random rng(7);
|
|
|
|
size_t strLen = 4 * GetReadaheadSize() +
|
|
|
|
rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
2020-07-09 23:33:42 +02:00
|
|
|
std::string str = rng.HumanReadableString(static_cast<int>(strLen));
|
2017-02-18 20:54:49 +01:00
|
|
|
ResetSourceStr(str);
|
|
|
|
for (int test = 1; test <= 100; ++test) {
|
|
|
|
size_t offset = rng.Uniform(static_cast<int>(strLen));
|
|
|
|
size_t n =
|
|
|
|
GetReadaheadSize() + rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
2019-07-17 03:18:07 +02:00
|
|
|
ASSERT_EQ(str.substr(offset, std::min(n, strLen - offset)),
|
2017-02-18 20:54:49 +01:00
|
|
|
Read(offset, n));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
EmptySourceStr, ReadaheadRandomAccessFileTest,
|
2017-02-18 20:54:49 +01:00
|
|
|
::testing::ValuesIn(ReadaheadRandomAccessFileTest::GetReadaheadSizeList()));
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
SourceStrLenLessThanReadaheadSize, ReadaheadRandomAccessFileTest,
|
2017-02-18 20:54:49 +01:00
|
|
|
::testing::ValuesIn(ReadaheadRandomAccessFileTest::GetReadaheadSizeList()));
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
SourceStrLenGreaterThanReadaheadSize, ReadaheadRandomAccessFileTest,
|
2017-02-18 20:54:49 +01:00
|
|
|
::testing::ValuesIn(ReadaheadRandomAccessFileTest::GetReadaheadSizeList()));
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
ReadExceedsReadaheadSize, ReadaheadRandomAccessFileTest,
|
2017-02-18 20:54:49 +01:00
|
|
|
::testing::ValuesIn(ReadaheadRandomAccessFileTest::GetReadaheadSizeList()));
|
|
|
|
|
2019-07-17 03:18:07 +02:00
|
|
|
class ReadaheadSequentialFileTest : public testing::Test,
|
|
|
|
public testing::WithParamInterface<size_t> {
|
|
|
|
public:
|
|
|
|
static std::vector<size_t> GetReadaheadSizeList() {
|
2019-07-18 02:01:30 +02:00
|
|
|
return {1lu << 8, 1lu << 12, 1lu << 16, 1lu << 18};
|
2019-07-17 03:18:07 +02:00
|
|
|
}
|
|
|
|
void SetUp() override {
|
|
|
|
readahead_size_ = GetParam();
|
|
|
|
scratch_.reset(new char[2 * readahead_size_]);
|
|
|
|
ResetSourceStr();
|
|
|
|
}
|
|
|
|
ReadaheadSequentialFileTest() {}
|
|
|
|
std::string Read(size_t n) {
|
|
|
|
Slice result;
|
2020-09-29 01:03:43 +02:00
|
|
|
Status s = test_read_holder_->Read(n, &result, scratch_.get());
|
|
|
|
EXPECT_TRUE(s.ok() || s.IsInvalidArgument());
|
2019-07-17 03:18:07 +02:00
|
|
|
return std::string(result.data(), result.size());
|
|
|
|
}
|
|
|
|
void Skip(size_t n) { test_read_holder_->Skip(n); }
|
|
|
|
void ResetSourceStr(const std::string& str = "") {
|
2021-01-05 00:59:52 +01:00
|
|
|
auto read_holder = std::unique_ptr<FSSequentialFile>(
|
2020-02-08 00:16:29 +01:00
|
|
|
new test::SeqStringSource(str, &seq_read_count_));
|
2021-01-05 00:59:52 +01:00
|
|
|
test_read_holder_.reset(new SequentialFileReader(std::move(read_holder),
|
|
|
|
"test", readahead_size_));
|
2019-07-17 03:18:07 +02:00
|
|
|
}
|
|
|
|
size_t GetReadaheadSize() const { return readahead_size_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t readahead_size_;
|
|
|
|
std::unique_ptr<SequentialFileReader> test_read_holder_;
|
|
|
|
std::unique_ptr<char[]> scratch_;
|
2020-02-08 00:16:29 +01:00
|
|
|
std::atomic<int> seq_read_count_;
|
2019-07-17 03:18:07 +02:00
|
|
|
};
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadSequentialFileTest, EmptySourceStr) {
|
2019-07-17 03:18:07 +02:00
|
|
|
ASSERT_EQ("", Read(0));
|
|
|
|
ASSERT_EQ("", Read(1));
|
|
|
|
ASSERT_EQ("", Read(13));
|
|
|
|
}
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadSequentialFileTest, SourceStrLenLessThanReadaheadSize) {
|
2019-07-17 03:18:07 +02:00
|
|
|
std::string str = "abcdefghijklmnopqrs";
|
|
|
|
ResetSourceStr(str);
|
|
|
|
ASSERT_EQ(str.substr(0, 3), Read(3));
|
|
|
|
ASSERT_EQ(str.substr(3, 1), Read(1));
|
|
|
|
ASSERT_EQ(str.substr(4), Read(str.size()));
|
|
|
|
ASSERT_EQ("", Read(100));
|
|
|
|
}
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadSequentialFileTest, SourceStrLenGreaterThanReadaheadSize) {
|
2019-07-17 03:18:07 +02:00
|
|
|
Random rng(42);
|
|
|
|
for (int s = 0; s < 1; ++s) {
|
|
|
|
for (int k = 0; k < 100; ++k) {
|
|
|
|
size_t strLen = k * GetReadaheadSize() +
|
|
|
|
rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
2020-07-09 23:33:42 +02:00
|
|
|
std::string str = rng.HumanReadableString(static_cast<int>(strLen));
|
2019-07-17 03:18:07 +02:00
|
|
|
ResetSourceStr(str);
|
|
|
|
size_t offset = 0;
|
|
|
|
for (int test = 1; test <= 100; ++test) {
|
|
|
|
size_t n = rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
|
|
|
if (s && test % 2) {
|
|
|
|
Skip(n);
|
|
|
|
} else {
|
|
|
|
ASSERT_EQ(str.substr(offset, std::min(n, strLen - offset)), Read(n));
|
|
|
|
}
|
|
|
|
offset = std::min(offset + n, strLen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-31 08:08:56 +01:00
|
|
|
TEST_P(ReadaheadSequentialFileTest, ReadExceedsReadaheadSize) {
|
2019-07-17 03:18:07 +02:00
|
|
|
Random rng(42);
|
|
|
|
for (int s = 0; s < 1; ++s) {
|
|
|
|
for (int k = 0; k < 100; ++k) {
|
|
|
|
size_t strLen = k * GetReadaheadSize() +
|
|
|
|
rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
2020-07-09 23:33:42 +02:00
|
|
|
std::string str = rng.HumanReadableString(static_cast<int>(strLen));
|
2019-07-17 03:18:07 +02:00
|
|
|
ResetSourceStr(str);
|
|
|
|
size_t offset = 0;
|
|
|
|
for (int test = 1; test <= 100; ++test) {
|
|
|
|
size_t n = GetReadaheadSize() +
|
|
|
|
rng.Uniform(static_cast<int>(GetReadaheadSize()));
|
|
|
|
if (s && test % 2) {
|
|
|
|
Skip(n);
|
|
|
|
} else {
|
|
|
|
ASSERT_EQ(str.substr(offset, std::min(n, strLen - offset)), Read(n));
|
|
|
|
}
|
|
|
|
offset = std::min(offset + n, strLen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
EmptySourceStr, ReadaheadSequentialFileTest,
|
2019-07-17 03:18:07 +02:00
|
|
|
::testing::ValuesIn(ReadaheadSequentialFileTest::GetReadaheadSizeList()));
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
SourceStrLenLessThanReadaheadSize, ReadaheadSequentialFileTest,
|
2019-07-17 03:18:07 +02:00
|
|
|
::testing::ValuesIn(ReadaheadSequentialFileTest::GetReadaheadSizeList()));
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
SourceStrLenGreaterThanReadaheadSize, ReadaheadSequentialFileTest,
|
2019-07-17 03:18:07 +02:00
|
|
|
::testing::ValuesIn(ReadaheadSequentialFileTest::GetReadaheadSizeList()));
|
2020-06-04 00:53:09 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
2020-01-31 08:08:56 +01:00
|
|
|
ReadExceedsReadaheadSize, ReadaheadSequentialFileTest,
|
2019-07-17 03:18:07 +02:00
|
|
|
::testing::ValuesIn(ReadaheadSequentialFileTest::GetReadaheadSizeList()));
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 23:46:15 +02:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|