mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Consistency Check Function
Summary: Added a function/command to check the consistency of live files' meta data Test Plan: Manual test (size mismatch, file not exist). Command test script. Reviewers: haobo Reviewed By: haobo CC: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D16935
This commit is contained in:
@@ -154,6 +154,8 @@ LDBCommand* LDBCommand::SelectCommand(
|
||||
return new ManifestDumpCommand(cmdParams, option_map, flags);
|
||||
} else if (cmd == InternalDumpCommand::Name()) {
|
||||
return new InternalDumpCommand(cmdParams, option_map, flags);
|
||||
} else if (cmd == CheckConsistencyCommand::Name()) {
|
||||
return new CheckConsistencyCommand(cmdParams, option_map, flags);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1749,5 +1751,29 @@ void DBQuerierCommand::DoCommand() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CheckConsistencyCommand::CheckConsistencyCommand(const vector<string>& params,
|
||||
const map<string, string>& options, const vector<string>& flags) :
|
||||
LDBCommand(options, flags, false,
|
||||
BuildCmdLineOptions({})) {
|
||||
}
|
||||
|
||||
void CheckConsistencyCommand::Help(string& ret) {
|
||||
ret.append(" ");
|
||||
ret.append(CheckConsistencyCommand::Name());
|
||||
ret.append("\n");
|
||||
}
|
||||
|
||||
void CheckConsistencyCommand::DoCommand() {
|
||||
Options opt = PrepareOptionsForOpenDB();
|
||||
if (!exec_state_.IsNotStarted()) {
|
||||
return;
|
||||
}
|
||||
Status st = DB::CheckConsistency(opt, db_path_);
|
||||
if (st.ok()) {
|
||||
fprintf(stdout, "OK\n");
|
||||
} else {
|
||||
exec_state_ = LDBCommandExecuteResult::FAILED(st.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
@@ -686,4 +686,20 @@ private:
|
||||
static const char* DELETE_CMD;
|
||||
};
|
||||
|
||||
class CheckConsistencyCommand : public LDBCommand {
|
||||
public:
|
||||
static string Name() { return "checkconsistency"; }
|
||||
|
||||
CheckConsistencyCommand(const vector<string>& params,
|
||||
const map<string, string>& options, const vector<string>& flags);
|
||||
|
||||
virtual void DoCommand();
|
||||
|
||||
virtual bool NoDBOpen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Help(string& ret);
|
||||
};
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
DeleteCommand::Help(ret);
|
||||
DBQuerierCommand::Help(ret);
|
||||
ApproxSizeCommand::Help(ret);
|
||||
CheckConsistencyCommand::Help(ret);
|
||||
|
||||
ret.append("\n\n");
|
||||
ret.append("Admin Commands:\n");
|
||||
|
||||
Reference in New Issue
Block a user