From e7ada9114e8d942a3e1d035eeeea6d57ec5759eb Mon Sep 17 00:00:00 2001 From: "wangyi.ywq" Date: Thu, 30 Jun 2022 20:22:07 +0800 Subject: [PATCH] fix manifest too large --- db/version_builder.cc | 2 +- db/version_set.cc | 32 ++++++++++++++++++++----- include/rocksdb/options.h | 2 +- utilities/checkpoint/checkpoint_impl.cc | 14 +++++++---- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/db/version_builder.cc b/db/version_builder.cc index f47d277602..b03ee2d655 100644 --- a/db/version_builder.cc +++ b/db/version_builder.cc @@ -879,7 +879,7 @@ bool VersionBuilder::CheckConsistencyForNumLevels() { void VersionBuilder::Apply(VersionEdit* edit) { // not change the current state - if(edit->check_point()) return; +// if(edit->check_point()) return; rep_->Apply(edit); } diff --git a/db/version_set.cc b/db/version_set.cc index 096c61a3c3..02caddbd85 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -3192,16 +3192,36 @@ Status VersionSet::ProcessManifestWrites(std::deque& writers, Status s; assert(pending_manifest_file_number_ == 0); - if (!descriptor_log_ || - manifest_file_size_ > db_options_->max_manifest_file_size || - manifest_edit_count_ > db_options_->max_manifest_edit_count) { - pending_manifest_file_number_ = NewFileNumber(); - batch_edits.back()->SetNextFile(next_file_number_.load()); - new_descriptor_log = true; + + bool cp = false; + for (auto e : batch_edits) { + if (e->check_point()) { + cp = true; + break; + } + } + if (!descriptor_log_) { + pending_manifest_file_number_ = NewFileNumber(); + batch_edits.back()->SetNextFile(next_file_number_.load()); + new_descriptor_log = true; } else { pending_manifest_file_number_ = manifest_file_number_; } +// if (!descriptor_log_ || +// manifest_file_size_ > db_options_->max_manifest_file_size || +// manifest_edit_count_ > db_options_->max_manifest_edit_count) { +// if (!descriptor_log_ || !cp) { +// pending_manifest_file_number_ = NewFileNumber(); +// batch_edits.back()->SetNextFile(next_file_number_.load()); +// new_descriptor_log = true; +// }else { +// pending_manifest_file_number_ = manifest_file_number_; +// } +// } else { +// pending_manifest_file_number_ = manifest_file_number_; +// } + if (new_descriptor_log) { // if we are writing out new snapshot make sure to persist max column // family. diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index 07ab6d0e74..0b48a058fe 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -993,7 +993,7 @@ struct DBOptions { // transaction is encountered in the WAL bool allow_2pc = false; - bool check_point_fake_flush = true; + bool check_point_fake_flush = false; // A global cache for table-level rows. // Default: nullptr (disabled) diff --git a/utilities/checkpoint/checkpoint_impl.cc b/utilities/checkpoint/checkpoint_impl.cc index f385df8870..bf65668eb6 100644 --- a/utilities/checkpoint/checkpoint_impl.cc +++ b/utilities/checkpoint/checkpoint_impl.cc @@ -205,12 +205,16 @@ Status CheckpointImpl::CreateCustomCheckpoint( } // this will return live_files prefixed with "/" - if(db_options.check_point_fake_flush){ + if (db_options.check_point_fake_flush) { s = db_->FakeFlush(fake_flush_files); - s = db_->GetLiveFiles(live_files, &manifest_file_size, false); - live_files.insert(live_files.end(), fake_flush_files.begin(), - fake_flush_files.end()); - }else{ + if (s.ok()) { + s = db_->GetLiveFiles(live_files, &manifest_file_size, false); + } + if (s.ok()) { + live_files.insert(live_files.end(), fake_flush_files.begin(), + fake_flush_files.end()); + } + } else { s = db_->GetLiveFiles(live_files, &manifest_file_size, flush_memtable); }