File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -55,11 +55,20 @@ TEST(RocksDBOption, interpret) {
5555 ASSERT_EQ (0 , r);
5656 ASSERT_TRUE (db->compact_on_mount );
5757 // check thread pool setting
58- options.env ->SleepForMicroseconds (100000 );
5958 std::vector<rocksdb::ThreadStatus> thread_list;
60- status = options.env ->GetThreadList (&thread_list);
61- ASSERT_TRUE (status.ok ());
62-
59+ /* Race hazard - rocksdb does not register its threads until they start
60+ * running, and only guarantees the threads have been created before
61+ * returning. We need to be prepared to wait for the scheduler to
62+ * run the threads to avoid false positives.
63+ */
64+ for (int attempt = 0 ; attempt < 50 ; attempt++) {
65+ options.env ->SleepForMicroseconds (100000 );
66+ status = options.env ->GetThreadList (&thread_list);
67+ ASSERT_TRUE (status.ok ());
68+ if (thread_list.size () >= 15u ) {
69+ break ;
70+ }
71+ }
6372 int num_high_pri_threads = 0 ;
6473 int num_low_pri_threads = 0 ;
6574 for (vector<rocksdb::ThreadStatus>::iterator it = thread_list.begin ();
You can’t perform that action at this time.
0 commit comments