From f5c8cf5feda1401b34a5e7c2b734487ad6322d39 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Wed, 14 Nov 2018 16:17:36 -0800 Subject: [PATCH] Increase wait time in DBTest.SanitizeNumThreads (#4659) Summary: DBTest.SanitizeNumThreads Sometimes fails. The test waited for 10ms timeout and expect all threads scheduled to be executed. This can be a source of flakiness. Make a check every 1ms and up to 10s. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4659 Differential Revision: D13074174 Pulled By: siying fbshipit-source-id: b1d5ff87a326a4fc9eab8d1cc307bbb940dfe70c --- db/db_test.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index ba196d9b2..5a9c39469 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -3512,8 +3512,14 @@ TEST_F(DBTest, SanitizeNumThreads) { (i < 4) ? Env::Priority::LOW : Env::Priority::HIGH); } - // Wait 100 milliseconds for they are scheduled. - env_->SleepForMicroseconds(100000); + // Wait until 10s for they are scheduled. + for (int i = 0; i < 10000; i++) { + if (options.env->GetThreadPoolQueueLen(Env::Priority::LOW) <= 1 && + options.env->GetThreadPoolQueueLen(Env::Priority::HIGH) <= 2) { + break; + } + env_->SleepForMicroseconds(1000); + } // pool size 3, total task 4. Queue size should be 1. ASSERT_EQ(1U, options.env->GetThreadPoolQueueLen(Env::Priority::LOW));