From 4496719450e5446e0fd9e0ef9271094db8a0bf75 Mon Sep 17 00:00:00 2001 From: zitan <11285749+gg814@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:08:41 -0700 Subject: [PATCH] Fix data race warning of BackupableDBTest.TableFileWithDbChecksumCorruptedDuringBackup (#7177) Summary: Fix the data race warning by removing an unnecessary variable that causes the warning. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7177 Test Plan: `COMPILE_WITH_TSAN=1 make backupable_db_test` `./backupable_db_test --gtest_filter=*TableFileWithDbChecksumCorruptedDuringBackup*` Reviewed By: riversand963 Differential Revision: D22774430 Pulled By: gg814 fbshipit-source-id: 3b0b1ac344d0375c64da564cc97f98745c289959 --- utilities/backupable/backupable_db_test.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/utilities/backupable/backupable_db_test.cc b/utilities/backupable/backupable_db_test.cc index 81e4fd456..6a706ff76 100644 --- a/utilities/backupable/backupable_db_test.cc +++ b/utilities/backupable/backupable_db_test.cc @@ -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", @@ -1312,18 +1312,15 @@ TEST_F(BackupableDBTest, TableFileWithDbChecksumCorruptedDuringBackup) { Slice* d = reinterpret_cast(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();