Fix for ReadaheadSequentialFile crash in ldb_cmd_test (#5586)
Summary: Fixing a corner case crash when there was no data read from file, but status is still OK Pull Request resolved: https://github.com/facebook/rocksdb/pull/5586 Differential Revision: D16348117 Pulled By: elipoz fbshipit-source-id: f97973308024f020d8be79ca3c56466b84d80656
This commit is contained in:
parent
8a008d4170
commit
9f5cfb8e71
@ -738,7 +738,7 @@ private:
|
||||
if (s.ok()) {
|
||||
buffer_offset_ = offset;
|
||||
buffer_.Size(result.size());
|
||||
assert(buffer_.BufferStart() == result.data());
|
||||
assert(result.size() == 0 || buffer_.BufferStart() == result.data());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -886,7 +886,7 @@ class ReadaheadSequentialFile : public SequentialFile {
|
||||
if (s.ok()) {
|
||||
buffer_offset_ = read_offset_;
|
||||
buffer_.Size(result.size());
|
||||
assert(buffer_.BufferStart() == result.data());
|
||||
assert(result.size() == 0 || buffer_.BufferStart() == result.data());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -1027,6 +1027,11 @@ std::unique_ptr<RandomAccessFile> NewReadaheadRandomAccessFile(
|
||||
std::unique_ptr<SequentialFile>
|
||||
SequentialFileReader::NewReadaheadSequentialFile(
|
||||
std::unique_ptr<SequentialFile>&& file, size_t readahead_size) {
|
||||
if (file->GetRequiredBufferAlignment() >= readahead_size) {
|
||||
// Short-circuit and return the original file if readahead_size is
|
||||
// too small and hence doesn't make sense to be used for prefetching.
|
||||
return std::move(file);
|
||||
}
|
||||
std::unique_ptr<SequentialFile> result(
|
||||
new ReadaheadSequentialFile(std::move(file), readahead_size));
|
||||
return result;
|
||||
|
@ -325,7 +325,7 @@ class ReadaheadSequentialFileTest : public testing::Test,
|
||||
public testing::WithParamInterface<size_t> {
|
||||
public:
|
||||
static std::vector<size_t> GetReadaheadSizeList() {
|
||||
return {1lu << 12, 1lu << 16};
|
||||
return {1lu << 8, 1lu << 12, 1lu << 16, 1lu << 18};
|
||||
}
|
||||
void SetUp() override {
|
||||
readahead_size_ = GetParam();
|
||||
|
Loading…
Reference in New Issue
Block a user