From 9425acacce56468a177cafbe5bfb940fcb97519b Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Tue, 26 Jan 2021 10:58:31 -0800 Subject: [PATCH] Fix flaky `error_handler_fs_test.MultiDBCompactionError` (#7896) Summary: The error recovery thread may out-live DBImpl object, which causing access released DBImpl.mutex. Close SstFileManager before closing DB. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7896 Test Plan: the issue can be reproduced by adding sleep in recovery code. Pass the tests with sleep. Reviewed By: zhichao-cao Differential Revision: D26076655 Pulled By: jay-zhuang fbshipit-source-id: 0d9cc5639c12fcfc001427015e75a9736f33cd96 --- db/error_handler_fs_test.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/error_handler_fs_test.cc b/db/error_handler_fs_test.cc index 80776c4480..399f3651e6 100644 --- a/db/error_handler_fs_test.cc +++ b/db/error_handler_fs_test.cc @@ -9,9 +9,9 @@ #ifndef ROCKSDB_LITE #include "db/db_test_util.h" +#include "file/sst_file_manager_impl.h" #include "port/stack_trace.h" #include "rocksdb/io_status.h" -#include "rocksdb/perf_context.h" #include "rocksdb/sst_file_manager.h" #if !defined(ROCKSDB_LITE) #include "test_util/sync_point.h" @@ -1391,6 +1391,10 @@ TEST_F(DBErrorHandlingFSTest, MultiDBCompactionError) { EXPECT_EQ(atoi(prop.c_str()), 1); } + SstFileManagerImpl* sfmImpl = + static_cast_with_check(sfm.get()); + sfmImpl->Close(); + for (auto i = 0; i < kNumDbInstances; ++i) { char buf[16]; snprintf(buf, sizeof(buf), "_%d", i); @@ -1524,6 +1528,10 @@ TEST_F(DBErrorHandlingFSTest, MultiDBVariousErrors) { EXPECT_EQ(atoi(prop.c_str()), 1); } + SstFileManagerImpl* sfmImpl = + static_cast_with_check(sfm.get()); + sfmImpl->Close(); + for (auto i = 0; i < kNumDbInstances; ++i) { char buf[16]; snprintf(buf, sizeof(buf), "_%d", i);