Modify verification logic of ObsoleteOptionsFileTest (#4218)

Summary:
The current verification logic does not consider the case in which multiple
threads (foreground and background) may execute `PurgeObsoleteFiles` function
simultaneously. Each invocation will trigger the callback adding elements to
a vector. Then we verify the elements in the vector, which can fail sometimes.

The solution is to give up checking the elements. Instead, we check the number
of OPTIONS file in the database dir.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4218

Differential Revision: D9128727

Pulled By: riversand963

fbshipit-source-id: 2b13b705fb21bc0ddd41940c4ec9b6b0c8d88224
main
Yanqin Jin 6 years ago committed by Facebook Github Bot
parent fefdac1004
commit 22368965a0
  1. 24
      db/obsolete_files_test.cc

@ -227,16 +227,24 @@ TEST_F(ObsoleteFilesTest, DeleteObsoleteOptionsFile) {
}
ASSERT_OK(dbi->EnableFileDeletions(true /* force */));
ASSERT_EQ(optsfiles_nums.size(), optsfiles_keep.size());
int size = static_cast<int>(optsfiles_nums.size());
int kept_opts_files_count = 0;
for (int i = 0; i != size; ++i) {
if (optsfiles_keep[i]) {
++kept_opts_files_count;
}
}
ASSERT_EQ(2, kept_opts_files_count);
CloseDB();
std::vector<std::string> files;
int opts_file_count = 0;
ASSERT_OK(env_->GetChildren(dbname_, &files));
for (const auto& file : files) {
uint64_t file_num;
Slice dummy_info_log_name_prefix;
FileType type;
WalFileType log_type;
if (ParseFileName(file, &file_num, dummy_info_log_name_prefix, &type,
&log_type) &&
type == kOptionsFile) {
opts_file_count++;
}
}
ASSERT_EQ(2, opts_file_count);
}
} //namespace rocksdb

Loading…
Cancel
Save