Skip to content

Commit f1a6759

Browse files
pdillingermeta-codesync[bot]
authored andcommitted
Fix flaky DBTestXactLogIterator.TransactionLogIteratorCheckWhenArchive (#14349)
Summary: a couple recent failures in this test. Waiting for purge and disabling sync points before Close should resolve the issues. Also fixing EventListenerTest.BlobDBOnFlushCompleted because it showed up as flaky in CI for this PR Pull Request resolved: #14349 Test Plan: watch CI Reviewed By: mszeszko-meta Differential Revision: D93619322 Pulled By: pdillinger fbshipit-source-id: bb9fc7d3c0ecaaeaffe4305e1ad403cbcd597484
1 parent 520c3ec commit f1a6759

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

db/db_log_iter_test.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,15 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorCheckWhenArchive) {
180180

181181
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
182182
ASSERT_OK(dbfull()->Flush(FlushOptions(), cf));
183+
// Try lots of things to ensure callback is triggered
184+
ASSERT_OK(dbfull()->TEST_SwitchWAL());
185+
ASSERT_OK(dbfull()->TEST_WaitForBackgroundWork());
186+
ASSERT_OK(dbfull()->TEST_WaitForPurge());
183187
delete cf;
184-
// Normally hit several times; WART: perhaps more in parallel after flush
185-
// FIXME: this test is flaky
186-
// ASSERT_TRUE(callback_hit.LoadRelaxed());
188+
ASSERT_TRUE(callback_hit.LoadRelaxed());
189+
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
190+
Close();
187191
} while (ChangeCompactOptions());
188-
Close();
189-
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
190192
}
191193
#endif
192194

db/listener_test.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,16 +1308,21 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13081308
explicit BlobDBJobLevelEventListenerTest(EventListenerTest* test)
13091309
: test_(test), call_count_(0) {}
13101310

1311-
const VersionStorageInfo* GetVersionStorageInfo() const {
1312-
VersionSet* const versions = test_->dbfull()->GetVersionSet();
1311+
// NOTE: it's not safe to rely on test_->db_ for these functions because
1312+
// the DB may be in the process of closing when these are called, and the
1313+
// unique_ptr is set to nullptr before invoking ~DB()
1314+
1315+
const VersionStorageInfo* GetVersionStorageInfo(DB* db) const {
1316+
DBImpl* db_impl = static_cast_with_check<DBImpl>(db);
1317+
VersionSet* const versions = db_impl->GetVersionSet();
13131318
assert(versions);
13141319

13151320
ColumnFamilyData* const cfd = versions->GetColumnFamilySet()->GetDefault();
13161321
EXPECT_NE(cfd, nullptr);
13171322

1318-
test_->dbfull()->TEST_LockMutex();
1323+
db_impl->TEST_LockMutex();
13191324
Version* const current = cfd->current();
1320-
test_->dbfull()->TEST_UnlockMutex();
1325+
db_impl->TEST_UnlockMutex();
13211326
EXPECT_NE(current, nullptr);
13221327

13231328
const VersionStorageInfo* const storage_info = current->storage_info();
@@ -1327,8 +1332,9 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13271332
}
13281333

13291334
void CheckBlobFileAdditions(
1335+
DB* db,
13301336
const std::vector<BlobFileAdditionInfo>& blob_file_addition_infos) const {
1331-
const auto* vstorage = GetVersionStorageInfo();
1337+
const auto* vstorage = GetVersionStorageInfo(db);
13321338

13331339
EXPECT_FALSE(blob_file_addition_infos.empty());
13341340

@@ -1356,7 +1362,7 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13561362
return result;
13571363
}
13581364

1359-
void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
1365+
void OnFlushCompleted(DB* db, const FlushJobInfo& info) override {
13601366
{
13611367
std::lock_guard<std::mutex> lock(mutex_);
13621368
IncreaseCallCount(/*mutex_locked*/ true);
@@ -1365,16 +1371,15 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13651371

13661372
EXPECT_EQ(info.blob_compression_type, kNoCompression);
13671373

1368-
CheckBlobFileAdditions(info.blob_file_addition_infos);
1374+
CheckBlobFileAdditions(db, info.blob_file_addition_infos);
13691375
}
13701376

1371-
void OnCompactionCompleted(DB* /*db*/,
1372-
const CompactionJobInfo& info) override {
1377+
void OnCompactionCompleted(DB* db, const CompactionJobInfo& info) override {
13731378
IncreaseCallCount(/*mutex_locked*/ false);
13741379

13751380
EXPECT_EQ(info.blob_compression_type, kNoCompression);
13761381

1377-
CheckBlobFileAdditions(info.blob_file_addition_infos);
1382+
CheckBlobFileAdditions(db, info.blob_file_addition_infos);
13781383

13791384
EXPECT_FALSE(info.blob_file_garbage_infos.empty());
13801385

0 commit comments

Comments
 (0)