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
main
Yueh-Hsuan Chiang 11 years ago
parent 625b9ef4e0
commit 570ba5aca8
  1. 5
      db/version_edit.h
  2. 6
      db/version_set.cc
  3. 3
      table/meta_blocks.cc

@ -81,6 +81,8 @@ struct FileMetaData {
uint64_t num_deletions; // the number of deletion entries. uint64_t num_deletions; // the number of deletion entries.
uint64_t raw_key_size; // total uncompressed key size. uint64_t raw_key_size; // total uncompressed key size.
uint64_t raw_value_size; // total uncompressed value 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() FileMetaData()
: refs(0), : refs(0),
@ -90,7 +92,8 @@ struct FileMetaData {
num_entries(0), num_entries(0),
num_deletions(0), num_deletions(0),
raw_key_size(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 // 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) { bool Version::MaybeInitializeFileMetaData(FileMetaData* file_meta) {
if (file_meta->num_entries > 0) { if (file_meta->init_stats_from_file) {
return false; return false;
} }
std::shared_ptr<const TableProperties> tp; std::shared_ptr<const TableProperties> tp;
Status s = GetTableProperties(&tp, file_meta); Status s = GetTableProperties(&tp, file_meta);
file_meta->init_stats_from_file = true;
if (!s.ok()) { 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; return false;
} }
if (tp.get() == nullptr) 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, s = ReadProperties(meta_iter->value(), file, footer, env, info_log,
properties); properties);
} else { } else {
s = Status::Corruption("Unable to read the property block."); s = Status::NotFound();
Log(WARN_LEVEL, info_log, "Cannot find Properties block from file.");
} }
return s; return s;

Loading…
Cancel
Save