Add is-file-deletions-enabled property
Summary: Add property 'rocksdb.is-file-deletions-enable' which equals disable_delete_obsole_file_ Test Plan: make all check Reviewers: sdong Reviewed By: sdong Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D22119
This commit is contained in:
parent
1755581f19
commit
9dcb75b6d9
@ -66,6 +66,10 @@ Status DBImpl::EnableFileDeletions(bool force) {
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DBImpl::IsFileDeletionsEnabled() const {
|
||||||
|
return disable_delete_obsolete_files_;
|
||||||
|
}
|
||||||
|
|
||||||
Status DBImpl::GetLiveFiles(std::vector<std::string>& ret,
|
Status DBImpl::GetLiveFiles(std::vector<std::string>& ret,
|
||||||
uint64_t* manifest_file_size,
|
uint64_t* manifest_file_size,
|
||||||
bool flush_memtable) {
|
bool flush_memtable) {
|
||||||
|
@ -4468,7 +4468,7 @@ bool DBImpl::GetIntPropertyInternal(ColumnFamilyHandle* column_family,
|
|||||||
|
|
||||||
if (!need_out_of_mutex) {
|
if (!need_out_of_mutex) {
|
||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
return cfd->internal_stats()->GetIntProperty(property_type, value);
|
return cfd->internal_stats()->GetIntProperty(property_type, value, this);
|
||||||
} else {
|
} else {
|
||||||
SuperVersion* sv = GetAndRefSuperVersion(cfd);
|
SuperVersion* sv = GetAndRefSuperVersion(cfd);
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ class DBImpl : public DB {
|
|||||||
#ifndef ROCKSDB_LITE
|
#ifndef ROCKSDB_LITE
|
||||||
virtual Status DisableFileDeletions();
|
virtual Status DisableFileDeletions();
|
||||||
virtual Status EnableFileDeletions(bool force);
|
virtual Status EnableFileDeletions(bool force);
|
||||||
|
virtual int IsFileDeletionsEnabled() const;
|
||||||
// All the returned filenames start with "/"
|
// All the returned filenames start with "/"
|
||||||
virtual Status GetLiveFiles(std::vector<std::string>&,
|
virtual Status GetLiveFiles(std::vector<std::string>&,
|
||||||
uint64_t* manifest_file_size,
|
uint64_t* manifest_file_size,
|
||||||
|
@ -1149,6 +1149,31 @@ TEST(DBTest, Empty) {
|
|||||||
|
|
||||||
ASSERT_EQ("v1", Get(1, "foo"));
|
ASSERT_EQ("v1", Get(1, "foo"));
|
||||||
env_->delay_sstable_sync_.Release_Store(nullptr); // Release sync calls
|
env_->delay_sstable_sync_.Release_Store(nullptr); // Release sync calls
|
||||||
|
|
||||||
|
ASSERT_OK(db_->DisableFileDeletions());
|
||||||
|
ASSERT_TRUE(
|
||||||
|
dbfull()->GetProperty("rocksdb.is-file-deletions-enabled", &num));
|
||||||
|
ASSERT_EQ("1", num);
|
||||||
|
|
||||||
|
ASSERT_OK(db_->DisableFileDeletions());
|
||||||
|
ASSERT_TRUE(
|
||||||
|
dbfull()->GetProperty("rocksdb.is-file-deletions-enabled", &num));
|
||||||
|
ASSERT_EQ("2", num);
|
||||||
|
|
||||||
|
ASSERT_OK(db_->DisableFileDeletions());
|
||||||
|
ASSERT_TRUE(
|
||||||
|
dbfull()->GetProperty("rocksdb.is-file-deletions-enabled", &num));
|
||||||
|
ASSERT_EQ("3", num);
|
||||||
|
|
||||||
|
ASSERT_OK(db_->EnableFileDeletions(false));
|
||||||
|
ASSERT_TRUE(
|
||||||
|
dbfull()->GetProperty("rocksdb.is-file-deletions-enabled", &num));
|
||||||
|
ASSERT_EQ("2", num);
|
||||||
|
|
||||||
|
ASSERT_OK(db_->EnableFileDeletions());
|
||||||
|
ASSERT_TRUE(
|
||||||
|
dbfull()->GetProperty("rocksdb.is-file-deletions-enabled", &num));
|
||||||
|
ASSERT_EQ("0", num);
|
||||||
} while (ChangeOptions());
|
} while (ChangeOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "db/column_family.h"
|
#include "db/column_family.h"
|
||||||
|
#include "db/db_impl.h"
|
||||||
|
|
||||||
namespace rocksdb {
|
namespace rocksdb {
|
||||||
|
|
||||||
@ -133,6 +134,8 @@ DBPropertyType GetPropertyType(const Slice& property, bool* is_int_property,
|
|||||||
} else if (in == "estimate-table-readers-mem") {
|
} else if (in == "estimate-table-readers-mem") {
|
||||||
*need_out_of_mutex = true;
|
*need_out_of_mutex = true;
|
||||||
return kEstimatedUsageByTableReaders;
|
return kEstimatedUsageByTableReaders;
|
||||||
|
} else if (in == "is-file-deletions-enabled") {
|
||||||
|
return kIsFileDeletionEnabled;
|
||||||
}
|
}
|
||||||
return kUnknown;
|
return kUnknown;
|
||||||
}
|
}
|
||||||
@ -215,7 +218,7 @@ bool InternalStats::GetStringProperty(DBPropertyType property_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool InternalStats::GetIntProperty(DBPropertyType property_type,
|
bool InternalStats::GetIntProperty(DBPropertyType property_type,
|
||||||
uint64_t* value) const {
|
uint64_t* value, DBImpl* db) const {
|
||||||
Version* current = cfd_->current();
|
Version* current = cfd_->current();
|
||||||
|
|
||||||
switch (property_type) {
|
switch (property_type) {
|
||||||
@ -254,6 +257,9 @@ bool InternalStats::GetIntProperty(DBPropertyType property_type,
|
|||||||
cfd_->imm()->current()->GetTotalNumEntries() +
|
cfd_->imm()->current()->GetTotalNumEntries() +
|
||||||
current->GetEstimatedActiveKeys();
|
current->GetEstimatedActiveKeys();
|
||||||
return true;
|
return true;
|
||||||
|
case kIsFileDeletionEnabled:
|
||||||
|
*value = db->IsFileDeletionsEnabled();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ enum DBPropertyType : uint32_t {
|
|||||||
// the immutable mem tables.
|
// the immutable mem tables.
|
||||||
kEstimatedNumKeys, // Estimated total number of keys in the database.
|
kEstimatedNumKeys, // Estimated total number of keys in the database.
|
||||||
kEstimatedUsageByTableReaders, // Estimated memory by table readers.
|
kEstimatedUsageByTableReaders, // Estimated memory by table readers.
|
||||||
|
kIsFileDeletionEnabled, // Equals disable_delete_obsolete_files_,
|
||||||
|
// 0 means file deletions enabled
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DBPropertyType GetPropertyType(const Slice& property,
|
extern DBPropertyType GetPropertyType(const Slice& property,
|
||||||
@ -197,7 +199,8 @@ class InternalStats {
|
|||||||
bool GetStringProperty(DBPropertyType property_type, const Slice& property,
|
bool GetStringProperty(DBPropertyType property_type, const Slice& property,
|
||||||
std::string* value);
|
std::string* value);
|
||||||
|
|
||||||
bool GetIntProperty(DBPropertyType property_type, uint64_t* value) const;
|
bool GetIntProperty(DBPropertyType property_type, uint64_t* value,
|
||||||
|
DBImpl* db) const;
|
||||||
|
|
||||||
bool GetIntPropertyOutOfMutex(DBPropertyType property_type, Version* version,
|
bool GetIntPropertyOutOfMutex(DBPropertyType property_type, Version* version,
|
||||||
uint64_t* value) const;
|
uint64_t* value) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user