From 9aec75fbb932fa7e1782436d28e490c554788608 Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Wed, 5 Aug 2015 11:47:07 -0700 Subject: [PATCH] Enable DBTest.FlushSchedule under TSAN Summary: This patch will fix the false positive of DBTest.FlushSchedule under TSAN, we dont need to disable this test Test Plan: COMPILE_WITH_TSAN=1 make -j64 db_test && ./db_test --gtest_filter="DBTest.FlushSchedule" Reviewers: yhchiang, sdong Reviewed By: sdong Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D43599 --- db/db_test.cc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index cb1b8b082..db4a75d44 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2293,9 +2293,6 @@ TEST_F(DBTest, RecoveryWithEmptyLog) { } -// false positive TSAN report on shared_ptr -- -// https://groups.google.com/forum/#!topic/thread-sanitizer/vz_s-t226Vg -#ifndef ROCKSDB_TSAN_RUN TEST_F(DBTest, FlushSchedule) { Options options = CurrentOptions(); options.disable_auto_compactions = true; @@ -2311,16 +2308,18 @@ TEST_F(DBTest, FlushSchedule) { std::atomic thread_num(0); // each column family will have 5 thread, each thread generating 2 memtables. // each column family should end up with 10 table files + std::function fill_memtable_func = [&]() { + int a = thread_num.fetch_add(1); + Random rnd(a); + WriteOptions wo; + // this should fill up 2 memtables + for (int k = 0; k < 5000; ++k) { + ASSERT_OK(db_->Put(wo, handles_[a & 1], RandomString(&rnd, 13), "")); + } + }; + for (int i = 0; i < 10; ++i) { - threads.emplace_back([&]() { - int a = thread_num.fetch_add(1); - Random rnd(a); - WriteOptions wo; - // this should fill up 2 memtables - for (int k = 0; k < 5000; ++k) { - ASSERT_OK(db_->Put(wo, handles_[a & 1], RandomString(&rnd, 13), "")); - } - }); + threads.emplace_back(fill_memtable_func); } for (auto& t : threads) { @@ -2334,7 +2333,6 @@ TEST_F(DBTest, FlushSchedule) { ASSERT_LE(pikachu_tables, static_cast(10)); ASSERT_GT(pikachu_tables, static_cast(0)); } -#endif // enabled only if not TSAN run TEST_F(DBTest, ManifestRollOver) {