From 8a139a054c4c194368fb010245a407e9e12b6be3 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Sat, 29 Mar 2014 10:34:47 -0700 Subject: [PATCH] More valgrind issues! Summary: Fix some more CompactionFilterV2 valgrind issues. Maybe it would make sense for CompactionFilterV2 to delete its prefix_extractor? Test Plan: ran CompactionFilterV2* tests with valgrind. issues before patch -> no issues after Reviewers: haobo, sdong, ljin, dhruba Reviewed By: dhruba CC: leveldb, danguo Differential Revision: https://reviews.facebook.net/D17337 --- db/db_test.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 0f007f791..8df456dfb 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -3707,9 +3707,11 @@ TEST(DBTest, CompactionFilterV2) { options.num_levels = 3; options.max_mem_compaction_level = 0; // extract prefix - auto prefix_extractor = NewFixedPrefixTransform(8); + std::unique_ptr prefix_extractor; + prefix_extractor.reset(NewFixedPrefixTransform(8)); + options.compaction_filter_factory_v2 - = std::make_shared(prefix_extractor); + = std::make_shared(prefix_extractor.get()); // In a testing environment, we can only flush the application // compaction filter buffer using universal compaction option_config_ = kUniversalCompaction; @@ -3757,7 +3759,7 @@ TEST(DBTest, CompactionFilterV2) { // create a new database with the compaction // filter in such a way that it deletes all keys options.compaction_filter_factory_v2 = - std::make_shared(prefix_extractor); + std::make_shared(prefix_extractor.get()); options.create_if_missing = true; DestroyAndReopen(&options); @@ -3792,9 +3794,10 @@ TEST(DBTest, CompactionFilterV2WithValueChange) { Options options = CurrentOptions(); options.num_levels = 3; options.max_mem_compaction_level = 0; - auto prefix_extractor = NewFixedPrefixTransform(8); + std::unique_ptr prefix_extractor; + prefix_extractor.reset(NewFixedPrefixTransform(8)); options.compaction_filter_factory_v2 = - std::make_shared(prefix_extractor); + std::make_shared(prefix_extractor.get()); // In a testing environment, we can only flush the application // compaction filter buffer using universal compaction option_config_ = kUniversalCompaction; @@ -3832,9 +3835,10 @@ TEST(DBTest, CompactionFilterV2NULLPrefix) { Options options = CurrentOptions(); options.num_levels = 3; options.max_mem_compaction_level = 0; - auto prefix_extractor = NewFixedPrefixTransform(8); + std::unique_ptr prefix_extractor; + prefix_extractor.reset(NewFixedPrefixTransform(8)); options.compaction_filter_factory_v2 = - std::make_shared(prefix_extractor); + std::make_shared(prefix_extractor.get()); // In a testing environment, we can only flush the application // compaction filter buffer using universal compaction option_config_ = kUniversalCompaction;