Disable PeriodicWorkScheduler during RateLimited test (#7810)

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

Reviewed By: akankshamahajan15

Differential Revision: D25695454

Pulled By: jay-zhuang

fbshipit-source-id: 963d11f38a959de7227ba2be15795af2792413a6
This commit is contained in:
Jay Zhuang 2021-01-11 15:00:55 -08:00 committed by Facebook GitHub Bot
parent fdbebdf484
commit 77b4bfe511
2 changed files with 20 additions and 0 deletions

View File

@ -703,6 +703,18 @@ void DBImpl::PrintStatistics() {
void DBImpl::StartPeriodicWorkScheduler() { void DBImpl::StartPeriodicWorkScheduler() {
#ifndef ROCKSDB_LITE #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_); InstrumentedMutexLock l(&mutex_);
periodic_work_scheduler_ = PeriodicWorkScheduler::Default(); periodic_work_scheduler_ = PeriodicWorkScheduler::Default();

View File

@ -374,6 +374,14 @@ TEST_F(DBSSTTest, RateLimitedDelete) {
*abs_time_us = Env::Default()->NowMicros(); *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<bool*>(arg);
*disable_scheduler = true;
});
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
Options options = CurrentOptions(); Options options = CurrentOptions();