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

Fix version set log (#17)

* fix version set log
Signed-off-by: 's avatarConnor1996 <zbk602423539@gmail.com>
parent 86d3e059
......@@ -85,6 +85,10 @@ BlobGCJob::BlobGCJob(BlobGC* blob_gc, DB* db, port::Mutex* mutex,
stats_(stats) {}
BlobGCJob::~BlobGCJob() {
if (log_buffer_) {
log_buffer_->FlushBufferToLog();
LogFlush(db_options_.info_log.get());
}
// flush metrics
RecordTick(stats_, BLOB_DB_BYTES_READ, metrics_.blob_db_bytes_read);
RecordTick(stats_, BLOB_DB_BYTES_WRITTEN, metrics_.blob_db_bytes_written);
......@@ -129,9 +133,6 @@ Status BlobGCJob::Run() {
blob_gc_->column_family_handle()->GetName().c_str(),
tmp.c_str(), tmp2.c_str());
log_buffer_->FlushBufferToLog();
LogFlush(db_options_.info_log.get());
if (blob_gc_->sampled_inputs().empty()) {
return Status::OK();
}
......@@ -445,12 +446,22 @@ Status BlobGCJob::InstallOutputBlobFiles() {
std::vector<std::pair<std::shared_ptr<BlobFileMeta>,
std::unique_ptr<BlobFileHandle>>>
files;
std::string tmp;
for (auto& builder : this->blob_file_builders_) {
auto file = std::make_shared<BlobFileMeta>(
builder.first->GetNumber(), builder.first->GetFile()->GetFileSize());
if (!tmp.empty()) {
tmp.append(" ");
}
tmp.append(std::to_string(file->file_number()));
blob_gc_->AddOutputFile(file.get());
files.emplace_back(std::make_pair(file, std::move(builder.first)));
}
ROCKS_LOG_BUFFER(log_buffer_, "[%s] output[%s]",
blob_gc_->column_family_handle()->GetName().c_str(),
tmp.c_str());
this->blob_file_manager_->BatchFinishFiles(
blob_gc_->column_family_handle()->GetID(), files);
} else {
......
......@@ -130,7 +130,6 @@ TitanDBImpl::TitanDBImpl(const TitanDBOptions& options,
if (db_options_.statistics != nullptr) {
stats_.reset(new TitanStats(db_options_.statistics.get()));
}
vset_.reset(new VersionSet(db_options_, stats_.get()));
blob_manager_.reset(new FileManager(this));
}
......@@ -183,6 +182,13 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs,
desc.options.disable_auto_compactions = true;
}
db_options_.avoid_flush_during_recovery = true;
// Add EventListener to collect statistics for GC
db_options_.listeners.emplace_back(std::make_shared<BaseDbListener>(this));
// Note that info log is initialized after `CreateLoggerFromOptions`,
// so new `VersionSet` here but not in constructor is to get a proper info
// log.
vset_.reset(new VersionSet(db_options_, stats_.get()));
s = DB::Open(db_options_, dbname_, init_descs, handles, &db_);
if (s.ok()) {
for (size_t i = 0; i < descs.size(); i++) {
......@@ -212,9 +218,6 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs,
s = vset_->Open(column_families);
if (!s.ok()) return s;
// Add EventListener to collect statistics for GC
db_options_.listeners.emplace_back(std::make_shared<BaseDbListener>(this));
static bool has_init_background_threads = false;
if (!has_init_background_threads) {
auto low_pri_threads_num = env_->GetBackgroundThreads(Env::Priority::LOW);
......
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