Fix valgrind issues
Summary:
NewFixedPrefixTransform is leaked in default options. Broken by b47812fba6
Also included in the diff some code cleanup
Test Plan:
valgrind env_test
also make check
Reviewers: haobo, danguo, yhchiang
Reviewed By: danguo
CC: leveldb
Differential Revision: https://reviews.facebook.net/D17211
This commit is contained in:
parent
d556200264
commit
1c9f8f0884
@ -70,7 +70,6 @@ namespace rocksdb {
|
|||||||
int DBImpl::SuperVersion::dummy = 0;
|
int DBImpl::SuperVersion::dummy = 0;
|
||||||
void* const DBImpl::SuperVersion::kSVInUse = &DBImpl::SuperVersion::dummy;
|
void* const DBImpl::SuperVersion::kSVInUse = &DBImpl::SuperVersion::dummy;
|
||||||
void* const DBImpl::SuperVersion::kSVObsolete = nullptr;
|
void* const DBImpl::SuperVersion::kSVObsolete = nullptr;
|
||||||
const std::string kNullString = "NULL";
|
|
||||||
|
|
||||||
void DumpLeveldbBuildVersion(Logger * log);
|
void DumpLeveldbBuildVersion(Logger * log);
|
||||||
|
|
||||||
@ -2897,7 +2896,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
|
|||||||
assert(compact);
|
assert(compact);
|
||||||
compact->CleanupBatchBuffer();
|
compact->CleanupBatchBuffer();
|
||||||
compact->CleanupMergedBuffer();
|
compact->CleanupMergedBuffer();
|
||||||
compact->cur_prefix_ = kNullString;
|
|
||||||
bool prefix_initialized = false;
|
bool prefix_initialized = false;
|
||||||
|
|
||||||
int64_t imm_micros = 0; // Micros spent doing imm_ compactions
|
int64_t imm_micros = 0; // Micros spent doing imm_ compactions
|
||||||
|
@ -139,6 +139,7 @@ class DefaultCompactionFilterFactory : public CompactionFilterFactory {
|
|||||||
//
|
//
|
||||||
class CompactionFilterFactoryV2 {
|
class CompactionFilterFactoryV2 {
|
||||||
public:
|
public:
|
||||||
|
// NOTE: CompactionFilterFactoryV2 will not delete prefix_extractor
|
||||||
explicit CompactionFilterFactoryV2(const SliceTransform* prefix_extractor)
|
explicit CompactionFilterFactoryV2(const SliceTransform* prefix_extractor)
|
||||||
: prefix_extractor_(prefix_extractor) { }
|
: prefix_extractor_(prefix_extractor) { }
|
||||||
|
|
||||||
@ -169,9 +170,8 @@ class CompactionFilterFactoryV2 {
|
|||||||
// return any filter
|
// return any filter
|
||||||
class DefaultCompactionFilterFactoryV2 : public CompactionFilterFactoryV2 {
|
class DefaultCompactionFilterFactoryV2 : public CompactionFilterFactoryV2 {
|
||||||
public:
|
public:
|
||||||
explicit DefaultCompactionFilterFactoryV2(
|
explicit DefaultCompactionFilterFactoryV2()
|
||||||
const SliceTransform* prefix_extractor)
|
: CompactionFilterFactoryV2(nullptr) { }
|
||||||
: CompactionFilterFactoryV2(prefix_extractor) { }
|
|
||||||
|
|
||||||
virtual std::unique_ptr<CompactionFilterV2>
|
virtual std::unique_ptr<CompactionFilterV2>
|
||||||
CreateCompactionFilterV2(
|
CreateCompactionFilterV2(
|
||||||
|
@ -126,6 +126,8 @@ struct Options {
|
|||||||
|
|
||||||
// Version TWO of the compaction_filter_factory
|
// Version TWO of the compaction_filter_factory
|
||||||
// It supports rolling compaction
|
// It supports rolling compaction
|
||||||
|
//
|
||||||
|
// Default: a factory that doesn't provide any object
|
||||||
std::shared_ptr<CompactionFilterFactoryV2> compaction_filter_factory_v2;
|
std::shared_ptr<CompactionFilterFactoryV2> compaction_filter_factory_v2;
|
||||||
|
|
||||||
// If true, the database will be created if it is missing.
|
// If true, the database will be created if it is missing.
|
||||||
|
@ -32,9 +32,7 @@ Options::Options()
|
|||||||
compaction_filter(nullptr),
|
compaction_filter(nullptr),
|
||||||
compaction_filter_factory(std::shared_ptr<CompactionFilterFactory>(
|
compaction_filter_factory(std::shared_ptr<CompactionFilterFactory>(
|
||||||
new DefaultCompactionFilterFactory())),
|
new DefaultCompactionFilterFactory())),
|
||||||
compaction_filter_factory_v2(
|
compaction_filter_factory_v2(new DefaultCompactionFilterFactoryV2()),
|
||||||
new DefaultCompactionFilterFactoryV2(
|
|
||||||
NewFixedPrefixTransform(8))),
|
|
||||||
create_if_missing(false),
|
create_if_missing(false),
|
||||||
error_if_exists(false),
|
error_if_exists(false),
|
||||||
paranoid_checks(false),
|
paranoid_checks(false),
|
||||||
|
Loading…
Reference in New Issue
Block a user