From 8a06fe278fe55005e08dc62457a43a9fc1b760da Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Mon, 7 Dec 2020 17:35:54 -0800 Subject: [PATCH] Do not use ASSERT_OK in child threads in ExternalSstFileTest.PickedLevelBug (#7754) Summary: `googletest` uses exceptions to communicate assertion failures when `GTEST_THROW_ON_FAILURE` is set, which does not go well with `std::thread`s, since an exception escaping the top-level function of an `std::thread` object or an `std::thread` getting destroyed without having been `join`ed or `detach`ed first results in a call to `std::terminate`. The patch fixes this by moving the `Status` assertions of background operations in `ExternalSstFileTest.PickedLevelBug` to the main thread. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7754 Test Plan: `make check` Reviewed By: riversand963 Differential Revision: D25383808 Pulled By: ltamasi fbshipit-source-id: 32fb2721e5169ec898d218900bc0d83eead45d03 --- db/external_sst_file_test.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/external_sst_file_test.cc b/db/external_sst_file_test.cc index c0be14e0a..519e0eae4 100644 --- a/db/external_sst_file_test.cc +++ b/db/external_sst_file_test.cc @@ -1345,15 +1345,18 @@ TEST_F(ExternalSSTFileTest, PickedLevelBug) { ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); // While writing the MANIFEST start a thread that will ask for compaction + Status bg_compact_status; ROCKSDB_NAMESPACE::port::Thread bg_compact([&]() { - ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr)); + bg_compact_status = + db_->CompactRange(CompactRangeOptions(), nullptr, nullptr); }); TEST_SYNC_POINT("ExternalSSTFileTest::PickedLevelBug:2"); // Start a thread that will ingest a new file + Status bg_addfile_status; ROCKSDB_NAMESPACE::port::Thread bg_addfile([&]() { file_keys = {1, 2, 3}; - ASSERT_OK(GenerateAndAddExternalFile(options, file_keys, 1)); + bg_addfile_status = GenerateAndAddExternalFile(options, file_keys, 1); }); // Wait for AddFile to start picking levels and writing MANIFEST @@ -1374,6 +1377,9 @@ TEST_F(ExternalSSTFileTest, PickedLevelBug) { bg_addfile.join(); bg_compact.join(); + ASSERT_OK(bg_addfile_status); + ASSERT_OK(bg_compact_status); + dbfull()->TEST_WaitForCompact(); int total_keys = 0;