From 69c98f043185f49ee1d83465b2eafe2afdef7c98 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Wed, 24 Feb 2016 10:32:11 -0800 Subject: [PATCH] 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 --- utilities/backupable/backupable_db_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utilities/backupable/backupable_db_test.cc b/utilities/backupable/backupable_db_test.cc index cc70f69b5..a53ae2df9 100644 --- a/utilities/backupable/backupable_db_test.cc +++ b/utilities/backupable/backupable_db_test.cc @@ -544,6 +544,10 @@ class BackupableDBTest : public testing::Test { std::string dbname_; 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_; + // envs Env* env_; unique_ptr mock_env_; @@ -558,7 +562,6 @@ class BackupableDBTest : public testing::Test { // options Options options_; - std::shared_ptr logger_; protected: unique_ptr backupable_options_;