From 534581a356c2cb544028c6b32179fdcba37d85fb Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Sun, 5 Mar 2017 18:01:28 -0800 Subject: [PATCH] Fix a bug in tests in options operator= Summary: Note: Using the default operator= is an unsafe approach for Options since it destructs shared_ptr in the same order of their creation, in contrast to destructors which destructs them in the opposite order of creation. One particular problme is that the cache destructor might invoke callback functions that use Option members such as statistics. To work around this problem, we manually call destructor of table_facotry which eventually clears the block cache. Closes https://github.com/facebook/rocksdb/pull/1950 Differential Revision: D4655473 Pulled By: maysamyabandeh fbshipit-source-id: 6c4bbff --- db/db_test_util.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/db_test_util.cc b/db/db_test_util.cc index 058347e3a..4b88b904c 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -511,6 +511,13 @@ Status DBTestBase::ReadOnlyReopen(const Options& options) { Status DBTestBase::TryReopen(const Options& options) { Close(); + last_options_.table_factory.reset(); + // Note: operator= is an unsafe approach here since it destructs shared_ptr in + // the same order of their creation, in contrast to destructors which + // destructs them in the opposite order of creation. One particular problme is + // that the cache destructor might invoke callback functions that use Option + // members such as statistics. To work around this problem, we manually call + // destructor of table_facotry which eventually clears the block cache. last_options_ = options; return DB::Open(options, dbname_, &db_); }