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
main
Levi Tamasi 4 years ago committed by Facebook GitHub Bot
parent ba2a3bf092
commit 8a06fe278f
  1. 10
      db/external_sst_file_test.cc

@ -1345,15 +1345,18 @@ TEST_F(ExternalSSTFileTest, PickedLevelBug) {
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// While writing the MANIFEST start a thread that will ask for compaction // While writing the MANIFEST start a thread that will ask for compaction
Status bg_compact_status;
ROCKSDB_NAMESPACE::port::Thread bg_compact([&]() { 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"); TEST_SYNC_POINT("ExternalSSTFileTest::PickedLevelBug:2");
// Start a thread that will ingest a new file // Start a thread that will ingest a new file
Status bg_addfile_status;
ROCKSDB_NAMESPACE::port::Thread bg_addfile([&]() { ROCKSDB_NAMESPACE::port::Thread bg_addfile([&]() {
file_keys = {1, 2, 3}; 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 // Wait for AddFile to start picking levels and writing MANIFEST
@ -1374,6 +1377,9 @@ TEST_F(ExternalSSTFileTest, PickedLevelBug) {
bg_addfile.join(); bg_addfile.join();
bg_compact.join(); bg_compact.join();
ASSERT_OK(bg_addfile_status);
ASSERT_OK(bg_compact_status);
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
int total_keys = 0; int total_keys = 0;

Loading…
Cancel
Save