Fix flaky EventListenerTest.DisableBGCompaction (#9400)

Summary:
Wasn't able to easily reproduce error, but easy to see a race
condition between TestFlushListener::OnFlushCompleted and
DBTestBase::Close(), which frees CF handles before closing DB.

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

Test Plan: CI etc.

Reviewed By: riversand963

Differential Revision: D33645134

Pulled By: pdillinger

fbshipit-source-id: d0ec914cc43c9e14f53da633876b95b61995138d
main
Peter Dillinger 3 years ago committed by Facebook GitHub Bot
parent cd50078ae0
commit 8064a3ac31
  1. 2
      db/db_impl/db_impl_debug.cc
  2. 3
      db/listener_test.cc

@ -159,7 +159,7 @@ Status DBImpl::TEST_AtomicFlushMemTables(
Status DBImpl::TEST_WaitForBackgroundWork() {
InstrumentedMutexLock l(&mutex_);
WaitForBackgroundWork();
return Status::OK();
return error_handler_.GetBGError();
}
Status DBImpl::TEST_WaitForFlushMemTable(ColumnFamilyHandle* column_family) {

@ -515,6 +515,9 @@ TEST_F(EventListenerTest, DisableBGCompaction) {
db_->GetColumnFamilyMetaData(handles_[1], &cf_meta);
}
ASSERT_GE(listener->slowdown_count, kSlowdownTrigger * 9);
// We don't want the listener executing during DBTestBase::Close() due to
// race on handles_.
ASSERT_OK(dbfull()->TEST_WaitForBackgroundWork());
}
class TestCompactionReasonListener : public EventListener {

Loading…
Cancel
Save