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
This commit is contained in:
sdong 2021-09-21 11:25:41 -07:00 committed by Facebook GitHub Bot
parent 5268cdc997
commit 1de588668c

View File

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