From b7ecf3d214a5c4f36aeb9824cd278844bf55c692 Mon Sep 17 00:00:00 2001 From: Venkatesh Radhakrishnan Date: Tue, 26 Jan 2016 09:12:20 -0800 Subject: [PATCH] Fix intermittent hang in ColumnFamilyTest.FlushAndDropRaceCondition Summary: ColumnFamilyTest.FlushAndDropRaceCondition sometimes hangs because the sync point, "FlushJob::InstallResults", sleeps holding the DB mutex. Fixing it by releasing the mutex before sleeping. Test Plan: seq 1000 |parallel --gnu --eta 't=/dev/shm/rdb-{}; rm -rf $t; mkdir $t && export TEST_TMPDIR=$t; ./column_family_test -gtest_filter=*FlushAndDropRaceCondition* > $t/log-{}' Reviewers: IslamAbdelRahman, anthony, kradhakrishnan, yhchiang, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D53349 --- db/column_family_test.cc | 4 +++- db/flush_job.cc | 1 + db/version_set.cc | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/column_family_test.cc b/db/column_family_test.cc index d86735c2e..62fadbbee 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -1999,7 +1999,9 @@ TEST_F(ColumnFamilyTest, FlushAndDropRaceCondition) { Reopen({options, options}); rocksdb::SyncPoint::GetInstance()->LoadDependency( - {{"VersionSet::LogAndApply::ColumnFamilyDrop:1", + {{"VersionSet::LogAndApply::ColumnFamilyDrop:0", + "FlushJob::WriteLevel0Table"}, + {"VersionSet::LogAndApply::ColumnFamilyDrop:1", "FlushJob::InstallResults"}, {"FlushJob::InstallResults", "VersionSet::LogAndApply::ColumnFamilyDrop:2"}}); diff --git a/db/flush_job.cc b/db/flush_job.cc index 9da7d9546..a565f8f25 100644 --- a/db/flush_job.cc +++ b/db/flush_job.cc @@ -270,6 +270,7 @@ Status FlushJob::WriteLevel0Table(const autovector& mems, if (!db_options_.disableDataSync && output_file_directory_ != nullptr) { output_file_directory_->Fsync(); } + TEST_SYNC_POINT("FlushJob::WriteLevel0Table"); db_mutex_->Lock(); } base->Unref(); diff --git a/db/version_set.cc b/db/version_set.cc index 519805396..235789512 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2218,6 +2218,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data, } if (edit->is_column_family_drop_) { + TEST_SYNC_POINT("VersionSet::LogAndApply::ColumnFamilyDrop:0"); TEST_SYNC_POINT("VersionSet::LogAndApply::ColumnFamilyDrop:1"); TEST_SYNC_POINT("VersionSet::LogAndApply::ColumnFamilyDrop:2"); }