Unverified Commit cb67cd56 authored by Connor's avatar Connor Committed by GitHub

fix wrong property after restart (#82)

Signed-off-by: 's avatarConnor1996 <zbk602423539@gmail.com>
parent c6e408c2
......@@ -256,6 +256,10 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs,
}
if (!s.ok()) return s;
if (stats_.get()) {
stats_->Initialize(column_families);
}
s = blob_file_set_->Open(column_families);
if (!s.ok()) return s;
......@@ -268,9 +272,6 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs,
s = DB::Open(db_options_, dbname_, base_descs, handles, &db_);
if (s.ok()) {
db_impl_ = reinterpret_cast<DBImpl*>(db_->GetRootDB());
if (stats_.get()) {
stats_->Initialize(column_families);
}
ROCKS_LOG_INFO(db_options_.info_log, "Titan DB open.");
ROCKS_LOG_HEADER(db_options_.info_log, "Titan git sha: %s",
titan_build_git_sha);
......
......@@ -13,6 +13,7 @@
#include "blob_file_size_collector.h"
#include "db_impl.h"
#include "db_iter.h"
#include "monitoring/statistics.h"
#include "titan/db.h"
#include "titan_fault_injection_test_env.h"
......@@ -38,6 +39,7 @@ class TitanDBTest : public testing::Test {
options_.merge_small_file_threshold = 0;
options_.disable_background_gc = true;
options_.blob_file_compression = CompressionType::kLZ4Compression;
options_.statistics = CreateDBStatistics();
DeleteDir(env_, options_.dirname);
DeleteDir(env_, dbname_);
}
......@@ -129,6 +131,10 @@ class TitanDBTest : public testing::Test {
}
}
bool GetIntProperty(const Slice& property, uint64_t* value) {
return db_->GetIntProperty(property, value);
}
std::weak_ptr<BlobStorage> GetBlobStorage(
ColumnFamilyHandle* cf_handle = nullptr) {
if (cf_handle == nullptr) {
......@@ -367,6 +373,20 @@ TEST_F(TitanDBTest, DBIterSeek) {
}
}
TEST_F(TitanDBTest, GetProperty) {
Open();
for (uint64_t k = 1; k <= 100; k++) {
Put(k);
}
Flush();
uint64_t value;
ASSERT_TRUE(GetIntProperty(TitanDB::Properties::kNumLiveBlobFile, &value));
ASSERT_EQ(value, 1);
Reopen();
ASSERT_TRUE(GetIntProperty(TitanDB::Properties::kNumLiveBlobFile, &value));
ASSERT_EQ(value, 1);
}
TEST_F(TitanDBTest, Snapshot) {
Open();
std::map<std::string, std::string> data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment