Skip to content

Commit

Permalink
Fix data race warning of BackupableDBTest.TableFileWithDbChecksumCorr…
Browse files Browse the repository at this point in the history
…uptedDuringBackup

Summary:
Fix the data race warning by removing an unnecessary variable that causes the warning.

Test plan:
`COMPILE_WITH_TSAN=1 make backupable_db_test`
`./backupable_db_test --gtest_filter=*TableFileWithDbChecksumCorruptedDuringBackup*`
  • Loading branch information
gg814 committed Jul 27, 2020
1 parent 69a6d0b commit 6701fcc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions utilities/backupable/backupable_db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ TEST_F(BackupableDBTest, TableFileWithDbChecksumCorruptedDuringBackup) {
OpenDBAndBackupEngine(true /* destroy_old_data */, false /* dummy */, sopt);

FillDB(db_.get(), 0, keys_iteration);
bool corrupted = false;

// corrupt files when copying to the backup directory
SyncPoint::GetInstance()->SetCallBack(
"BackupEngineImpl::CopyOrCreateFile:CorruptionDuringBackup",
Expand All @@ -1312,18 +1312,15 @@ TEST_F(BackupableDBTest, TableFileWithDbChecksumCorruptedDuringBackup) {
Slice* d = reinterpret_cast<Slice*>(data);
if (!d->empty()) {
d->remove_suffix(1);
corrupted = true;
}
}
});
SyncPoint::GetInstance()->EnableProcessing();
Status s = backup_engine_->CreateNewBackup(db_.get());
if (corrupted) {
ASSERT_NOK(s);
} else {
// should not in this path in normal cases
ASSERT_OK(s);
}
// The only case that we can't detect a corruption is when the file
// being backed up is empty. But as keys_iteration is large, such
// a case shouldn't have happened and we should be able to detect
// the corruption.
ASSERT_NOK(backup_engine_->CreateNewBackup(db_.get()));

SyncPoint::GetInstance()->DisableProcessing();
SyncPoint::GetInstance()->ClearAllCallBacks();
Expand Down

0 comments on commit 6701fcc

Please sign in to comment.