From: Bill Scales Date: Thu, 20 Jun 2024 09:46:17 +0000 (+0000) Subject: test/objectstore/TestRocksdbOptionParse.cc: Fix race hazard X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e87974613cc25538e7ee6ec8faf93ef76869a9fe;p=ceph.git test/objectstore/TestRocksdbOptionParse.cc: Fix race hazard Race hazard - rocksdb does not register its threads until they start running, and only guarantees the threads have been created before returning. We need to be prepared to wait for the scheduler to run the threads to avoid false positives. Fixes: https://tracker.ceph.com/issues/66575 Signed-off-by: Bill Scales --- diff --git a/src/test/objectstore/TestRocksdbOptionParse.cc b/src/test/objectstore/TestRocksdbOptionParse.cc index 986eea8f16ce..763b951cb8a7 100644 --- a/src/test/objectstore/TestRocksdbOptionParse.cc +++ b/src/test/objectstore/TestRocksdbOptionParse.cc @@ -55,11 +55,20 @@ TEST(RocksDBOption, interpret) { ASSERT_EQ(0, r); ASSERT_TRUE(db->compact_on_mount); //check thread pool setting - options.env->SleepForMicroseconds(100000); std::vector thread_list; - status = options.env->GetThreadList(&thread_list); - ASSERT_TRUE(status.ok()); - + /* Race hazard - rocksdb does not register its threads until they start + * running, and only guarantees the threads have been created before + * returning. We need to be prepared to wait for the scheduler to + * run the threads to avoid false positives. + */ + for (int attempt = 0; attempt < 50; attempt++) { + options.env->SleepForMicroseconds(100000); + status = options.env->GetThreadList(&thread_list); + ASSERT_TRUE(status.ok()); + if (thread_list.size() >= 15u) { + break; + } + } int num_high_pri_threads = 0; int num_low_pri_threads = 0; for (vector::iterator it = thread_list.begin();