Fix flaky ldb_cmd_test tests caused by file deletions during validation (#8942)

Summary:
In FileChecksumTestHelper::VerifyEachFileChecksum(), we query the file list, and then for each file in the list verify the checksum. However, compaction can delete those files in the mean time and cause failures. To prevent it from happening, disable file deletion during the validation.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8942

Test Plan: Run exsiting test and see it doesn't fail.

Reviewed By: pdillinger

Differential Revision: D31086488

fbshipit-source-id: 554608f36d2dd3bf0a20dfc4039c68bd8533d7f8
main
sdong 3 years ago committed by Facebook GitHub Bot
parent 5268cdc997
commit 1de588668c
  1. 9
      tools/ldb_cmd_test.cc

@ -254,15 +254,18 @@ class FileChecksumTestHelper {
// comparing it with the one being generated when a SST file is created. // comparing it with the one being generated when a SST file is created.
Status VerifyEachFileChecksum() { Status VerifyEachFileChecksum() {
assert(db_ != nullptr); assert(db_ != nullptr);
EXPECT_OK(db_->DisableFileDeletions());
std::vector<LiveFileMetaData> live_files; std::vector<LiveFileMetaData> live_files;
db_->GetLiveFilesMetaData(&live_files); db_->GetLiveFilesMetaData(&live_files);
Status cs;
for (auto a_file : live_files) { for (auto a_file : live_files) {
Status cs = VerifyChecksum(a_file); cs = VerifyChecksum(a_file);
if (!cs.ok()) { if (!cs.ok()) {
return cs; break;
} }
} }
return Status::OK(); EXPECT_OK(db_->EnableFileDeletions());
return cs;
} }
}; };

Loading…
Cancel
Save