Ignore comparator name mismatch in ldb manifest dump (#8216)
Summary: RocksDB allows user-specified custom comparators which may not be known to `ldb`, a built-in tool for checking/mutating the database. Therefore, column family comparator names mismatch encountered during manifest dump should not prevent the dumping from proceeding. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8216 Test Plan: ``` make check ``` Also manually do the following ``` KEEP_DB=1 ./db_with_timestamp_basic_test ./ldb --db=<db> manifest_dump --verbose ``` The ldb should succeed and print something like: ``` ... --------------- Column family "default" (ID 0) -------------- log number: 6 comparator: <TestComparator>, but the comparator object is not available. ... ``` Reviewed By: ltamasi Differential Revision: D27927581 Pulled By: riversand963 fbshipit-source-id: f610b2c842187d17f575362070209ee6b74ec6d4
This commit is contained in:
parent
4985cea141
commit
314352761f
|
@ -553,9 +553,13 @@ Status VersionEditHandler::ExtractInfoFromVersionEdit(ColumnFamilyData* cfd,
|
||||||
}
|
}
|
||||||
if (edit.has_comparator_ &&
|
if (edit.has_comparator_ &&
|
||||||
edit.comparator_ != cfd->user_comparator()->Name()) {
|
edit.comparator_ != cfd->user_comparator()->Name()) {
|
||||||
s = Status::InvalidArgument(
|
if (!cf_to_cmp_names_) {
|
||||||
cfd->user_comparator()->Name(),
|
s = Status::InvalidArgument(
|
||||||
"does not match existing comparator " + edit.comparator_);
|
cfd->user_comparator()->Name(),
|
||||||
|
"does not match existing comparator " + edit.comparator_);
|
||||||
|
} else {
|
||||||
|
cf_to_cmp_names_->emplace(cfd->GetID(), edit.comparator_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (edit.HasFullHistoryTsLow()) {
|
if (edit.HasFullHistoryTsLow()) {
|
||||||
const std::string& new_ts = edit.GetFullHistoryTsLow();
|
const std::string& new_ts = edit.GetFullHistoryTsLow();
|
||||||
|
@ -889,13 +893,21 @@ void DumpManifestHandler::CheckIterationResult(const log::Reader& reader,
|
||||||
fprintf(stdout, "%s\n", s->ToString().c_str());
|
fprintf(stdout, "%s\n", s->ToString().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
assert(cf_to_cmp_names_);
|
||||||
for (auto* cfd : *(version_set_->column_family_set_)) {
|
for (auto* cfd : *(version_set_->column_family_set_)) {
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"--------------- Column family \"%s\" (ID %" PRIu32
|
"--------------- Column family \"%s\" (ID %" PRIu32
|
||||||
") --------------\n",
|
") --------------\n",
|
||||||
cfd->GetName().c_str(), cfd->GetID());
|
cfd->GetName().c_str(), cfd->GetID());
|
||||||
fprintf(stdout, "log number: %" PRIu64 "\n", cfd->GetLogNumber());
|
fprintf(stdout, "log number: %" PRIu64 "\n", cfd->GetLogNumber());
|
||||||
fprintf(stdout, "comparator: %s\n", cfd->user_comparator()->Name());
|
auto it = cf_to_cmp_names_->find(cfd->GetID());
|
||||||
|
if (it != cf_to_cmp_names_->end()) {
|
||||||
|
fprintf(stdout,
|
||||||
|
"comparator: <%s>, but the comparator object is not available.\n",
|
||||||
|
it->second.c_str());
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "comparator: %s\n", cfd->user_comparator()->Name());
|
||||||
|
}
|
||||||
assert(cfd->current());
|
assert(cfd->current());
|
||||||
fprintf(stdout, "%s \n", cfd->current()->DebugString(hex_).c_str());
|
fprintf(stdout, "%s \n", cfd->current()->DebugString(hex_).c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,7 @@ class VersionEditHandler : public VersionEditHandlerBase {
|
||||||
std::shared_ptr<IOTracer> io_tracer_;
|
std::shared_ptr<IOTracer> io_tracer_;
|
||||||
bool skip_load_table_files_;
|
bool skip_load_table_files_;
|
||||||
bool initialized_;
|
bool initialized_;
|
||||||
|
std::unique_ptr<std::unordered_map<uint32_t, std::string>> cf_to_cmp_names_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Status ExtractInfoFromVersionEdit(ColumnFamilyData* cfd,
|
Status ExtractInfoFromVersionEdit(ColumnFamilyData* cfd,
|
||||||
|
@ -275,7 +276,9 @@ class DumpManifestHandler : public VersionEditHandler {
|
||||||
verbose_(verbose),
|
verbose_(verbose),
|
||||||
hex_(hex),
|
hex_(hex),
|
||||||
json_(json),
|
json_(json),
|
||||||
count_(0) {}
|
count_(0) {
|
||||||
|
cf_to_cmp_names_.reset(new std::unordered_map<uint32_t, std::string>());
|
||||||
|
}
|
||||||
|
|
||||||
~DumpManifestHandler() override {}
|
~DumpManifestHandler() override {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user