diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 62f26bf82..f4e8e8e31 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -703,6 +703,18 @@ void DBImpl::PrintStatistics() { void DBImpl::StartPeriodicWorkScheduler() { #ifndef ROCKSDB_LITE + +#ifndef NDEBUG + // It only used by test to disable scheduler + bool disable_scheduler = false; + TEST_SYNC_POINT_CALLBACK( + "DBImpl::StartPeriodicWorkScheduler:DisableScheduler", + &disable_scheduler); + if (disable_scheduler) { + return; + } +#endif // !NDEBUG + { InstrumentedMutexLock l(&mutex_); periodic_work_scheduler_ = PeriodicWorkScheduler::Default(); diff --git a/db/db_sst_test.cc b/db/db_sst_test.cc index ed1d50d3d..7987daa80 100644 --- a/db/db_sst_test.cc +++ b/db/db_sst_test.cc @@ -374,6 +374,14 @@ TEST_F(DBSSTTest, RateLimitedDelete) { *abs_time_us = Env::Default()->NowMicros(); }); + // Disable PeriodicWorkScheduler as it also has TimedWait, which could update + // the simulated sleep time + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( + "DBImpl::StartPeriodicWorkScheduler:DisableScheduler", [&](void* arg) { + bool* disable_scheduler = static_cast(arg); + *disable_scheduler = true; + }); + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); Options options = CurrentOptions();