-
Notifications
You must be signed in to change notification settings - Fork 211
Ldb kv recover #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yapple
wants to merge
11
commits into
dev.1.4
Choose a base branch
from
ldb_kv_recover
base: dev.1.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ldb kv recover #198
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
258a8e0
1. add manifestrollback command, don't need open db.
yapple 085fa2b
1. add Next File Number edit record
yapple abf5d2d
1. fix recover failed capture
yapple a372080
1. fix descriptor no largest-sequence-number entry
yapple 51bcc46
1. fix descriptor no largest-sequence-number entry v2
yapple fa1116d
1. fix descriptor no largest-sequence-number entry v3
yapple 64a7b77
1. add KvCombineCommand, we use compactFile to
yapple ebe8bc3
1. KvCombineCommand add parallel param and support threadpool to para…
yapple 588ca74
1. KvCombineCommand add rate_limiter_bytes_per_sec support write rate…
yapple 47f0a66
1. KvCombineCommand add rate_limiter_bytes_per_sec support write rate…
yapple dd4e794
1. initial combine command, close auto compaction and load options
yapple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2992,7 +2992,59 @@ void VersionSet::AppendVersion(ColumnFamilyData* column_family_data, | |
| v->prev_->next_ = v; | ||
| v->next_->prev_ = v; | ||
| } | ||
| Status VersionSet::ManifestRollback(InstrumentedMutex* mu) { | ||
| Status s; | ||
| pending_manifest_file_number_ = NewFileNumber(); | ||
| std::string descriptor_fname = | ||
| DescriptorFileName(dbname_, pending_manifest_file_number_); | ||
| std::unique_ptr<WritableFile> descriptor_file; | ||
| EnvOptions opt_env_opts = env_->OptimizeForManifestWrite(env_options_); | ||
| s = NewWritableFile(env_, descriptor_fname, &descriptor_file, | ||
| opt_env_opts); | ||
| if (s.ok()) { | ||
| descriptor_file->SetPreallocationBlockSize( | ||
| db_options_->manifest_preallocation_size); | ||
|
|
||
| std::unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter( | ||
| std::move(descriptor_file), descriptor_fname, opt_env_opts, nullptr, | ||
| db_options_->listeners)); | ||
| descriptor_log_.reset( | ||
| new log::Writer(std::move(file_writer), 0, false)); | ||
| s = WriteSnapshot(descriptor_log_.get(), true); | ||
| } | ||
| do { | ||
| if(s.ok()) { | ||
| VersionEdit e; | ||
| for(auto cfd : *column_family_set_) { | ||
| LogAndApplyHelper(cfd, nullptr, cfd->current(), &e, mu, false); | ||
| } | ||
| std::string record; | ||
| if (!e.EncodeTo(&record)) { | ||
| s = Status::Corruption("Unable to encode VersionEdit:" + | ||
| e.DebugString(true)); | ||
| } | ||
| s = descriptor_log_->AddRecord(record); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 未检查 s |
||
| if (!s.ok()) { | ||
| break; | ||
| } | ||
| if (s.ok()) { | ||
| s = SyncManifest(env_, db_options_, descriptor_log_->file()); | ||
| } | ||
| if (!s.ok()) { | ||
| ROCKS_LOG_ERROR(db_options_->info_log, "MANIFEST write %s\n", | ||
| s.ToString().c_str()); | ||
| } | ||
| } | ||
| }while(false); | ||
|
|
||
| if (s.ok()) { | ||
| s = SetCurrentFile(env_, dbname_, pending_manifest_file_number_,nullptr); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| return s; | ||
| } | ||
| Status VersionSet::ProcessManifestWrites(std::deque<ManifestWriter>& writers, | ||
| InstrumentedMutex* mu, | ||
| Directory* db_directory, | ||
|
|
@@ -4339,7 +4391,7 @@ void VersionSet::MarkMinLogNumberToKeep2PC(uint64_t number) { | |
| } | ||
| } | ||
|
|
||
| Status VersionSet::WriteSnapshot(log::Writer* log) { | ||
| Status VersionSet::WriteSnapshot(log::Writer* log, const bool rollback) { | ||
| // TODO: Break up into multiple records to reduce memory usage on recovery? | ||
|
|
||
| // WARNING: This method doesn't hold a mutex!! | ||
|
|
@@ -4348,6 +4400,9 @@ Status VersionSet::WriteSnapshot(log::Writer* log) { | |
| // LogAndApply. Column family manipulations can only happen within LogAndApply | ||
| // (the same single thread), so we're safe to iterate. | ||
| for (auto cfd : *column_family_set_) { | ||
| if(rollback && cfd->current()->storage_info()->LevelFiles(-1).size() != 0){ | ||
| return Status::Corruption("cfd: %s's level -1 is not null", cfd->GetName()); | ||
| } | ||
| if (cfd->IsDropped()) { | ||
| continue; | ||
| } | ||
|
|
@@ -4377,6 +4432,9 @@ Status VersionSet::WriteSnapshot(log::Writer* log) { | |
| { | ||
| // Save files | ||
| VersionEdit edit; | ||
| if(rollback) { | ||
| edit.setRollback(); | ||
| } | ||
| edit.SetColumnFamily(cfd->GetID()); | ||
|
|
||
| for (int level = -1; level < cfd->NumberLevels(); level++) { | ||
|
|
@@ -4759,6 +4817,9 @@ void VersionSet::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) { | |
| filemetadata.being_compacted = file->being_compacted; | ||
| filemetadata.num_entries = file->prop.num_entries; | ||
| filemetadata.num_deletions = file->prop.num_deletions; | ||
| if(file->prop.dependence.size() != 0 || file->prop.inheritance.size() !=0 || !file->prop.is_essense_sst()) { | ||
| filemetadata.non_origin_file = true; | ||
| } | ||
| metadata->push_back(filemetadata); | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,8 @@ struct SstFileMetaData { | |
| num_reads_sampled(0), | ||
| being_compacted(false), | ||
| num_entries(0), | ||
| num_deletions(0) {} | ||
| num_deletions(0), | ||
| non_origin_file(false) {} | ||
|
|
||
| SstFileMetaData(const std::string& _file_name, const std::string& _path, | ||
| size_t _size, SequenceNumber _smallest_seqno, | ||
|
|
@@ -83,7 +84,8 @@ struct SstFileMetaData { | |
| num_reads_sampled(_num_reads_sampled), | ||
| being_compacted(_being_compacted), | ||
| num_entries(0), | ||
| num_deletions(0) {} | ||
| num_deletions(0), | ||
| non_origin_file(false) {} | ||
|
|
||
| // File size in bytes. | ||
| size_t size; | ||
|
|
@@ -101,6 +103,8 @@ struct SstFileMetaData { | |
|
|
||
| uint64_t num_entries; | ||
| uint64_t num_deletions; | ||
| // true Means a terarkdb sst file instead of rocksdb file | ||
| bool non_origin_file; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 移动一下 bool 定义的位置,尽可能让 bool 全都挨着 |
||
| }; | ||
|
|
||
| // The full set of metadata associated with each SST file. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
调整一下变量定义的位置,尽量让所有的 bool 挨在一起