Skip to content

Commit

Permalink
Avoid retrying to read property block from a table when it does not e…
Browse files Browse the repository at this point in the history
…xist.

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
  • Loading branch information
yhchiang committed Aug 15, 2014
1 parent 625b9ef commit 570ba5a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion db/version_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions table/meta_blocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 570ba5a

Please sign in to comment.