提交 570ba5ac 编写于 作者: Y Yueh-Hsuan Chiang

Avoid retrying to read property block from a table when it does not exist.

Summary:
Avoid retrying to read property block from a table when it does not exist
in updating stats for compensating deletion entries.

In addition, ReadTableProperties() now returns Status::NotFound instead
of Status::Corruption when table properties does not exist in the file.

Test Plan:
make db_test -j32
export ROCKSDB_TESTS=CompactionDeleteionTrigger
./db_test

Reviewers: ljin, sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21867
上级 625b9ef4
......@@ -81,6 +81,8 @@ struct FileMetaData {
uint64_t num_deletions; // the number of deletion entries.
uint64_t raw_key_size; // total uncompressed key size.
uint64_t raw_value_size; // total uncompressed value size.
bool init_stats_from_file; // true if the data-entry stats of this file
// has initialized from file.
FileMetaData()
: refs(0),
......@@ -90,7 +92,8 @@ struct FileMetaData {
num_entries(0),
num_deletions(0),
raw_key_size(0),
raw_value_size(0) {}
raw_value_size(0),
init_stats_from_file(false) {}
};
// A compressed copy of file meta data that just contain
......
......@@ -879,12 +879,16 @@ void Version::PrepareApply(std::vector<uint64_t>& size_being_compacted) {
}
bool Version::MaybeInitializeFileMetaData(FileMetaData* file_meta) {
if (file_meta->num_entries > 0) {
if (file_meta->init_stats_from_file) {
return false;
}
std::shared_ptr<const TableProperties> tp;
Status s = GetTableProperties(&tp, file_meta);
file_meta->init_stats_from_file = true;
if (!s.ok()) {
Log(vset_->options_->info_log,
"Unable to load table properties for file %" PRIu64 " --- %s\n",
file_meta->fd.GetNumber(), s.ToString().c_str());
return false;
}
if (tp.get() == nullptr) return false;
......
......@@ -253,8 +253,7 @@ Status ReadTableProperties(RandomAccessFile* file, uint64_t file_size,
s = ReadProperties(meta_iter->value(), file, footer, env, info_log,
properties);
} else {
s = Status::Corruption("Unable to read the property block.");
Log(WARN_LEVEL, info_log, "Cannot find Properties block from file.");
s = Status::NotFound();
}
return s;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册