Reorder instance variables in backup test for proper destruction order

Summary:
As titled. This fixes the tsan error caused by logger_ being used in
backup_engine_'s destructor. It does not fix the transient unit test failure,
which is caused by MANIFEST file changing while backup is happening.

Test Plan:
verified the tsan error no longer happens on either success or
failure.

  $ COMPILE_WITH_TSAN=1 make -j32 backupable_db_test
  $ while ./backupable_db_test --gtest_filter=BackupableDBTest.CorruptionsTest ; do : ; done

Reviewers: sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D54669
This commit is contained in:
Andrew Kryczka 2016-02-24 10:32:11 -08:00
parent 82f15fb15d
commit 69c98f0431

View File

@ -544,6 +544,10 @@ class BackupableDBTest : public testing::Test {
std::string dbname_; std::string dbname_;
std::string backupdir_; std::string backupdir_;
// logger_ must be above backup_engine_ such that the engine's destructor,
// which uses a raw pointer to the logger, executes first.
std::shared_ptr<Logger> logger_;
// envs // envs
Env* env_; Env* env_;
unique_ptr<MockEnv> mock_env_; unique_ptr<MockEnv> mock_env_;
@ -558,7 +562,6 @@ class BackupableDBTest : public testing::Test {
// options // options
Options options_; Options options_;
std::shared_ptr<Logger> logger_;
protected: protected:
unique_ptr<BackupableDBOptions> backupable_options_; unique_ptr<BackupableDBOptions> backupable_options_;