Commit d9ec28f8 authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

raft: show resilvering progress in raft-info

parent 9931243d
Pipeline #1582259 passed with stages
in 149 minutes and 49 seconds
......@@ -11,6 +11,7 @@ corruption was flaky, and would sometimes report a problem where none existed.
or otherwise flaky rejoining servers from triggering unnecessary and disruptive elections.
A node will first issue an experimental voting round before advancing its term, and start campaigning
for earnest only if it has a good chance of winning.
- Show resilvering progress in ``raft-info``.
Many thanks to Franck Eyraud (JRC) for the bug report concerning erroneous ``MANIFEST``-related
warning.
......
......@@ -250,10 +250,11 @@ struct ReplicaStatus {
bool online;
LogIndex logSize;
std::string version;
int resilveringProgress;
ReplicaStatus() {}
ReplicaStatus(const RaftServer &trg, bool onl, LogIndex indx, const std::string &ver = "N/A")
: target(trg), online(onl), logSize(indx), version(ver) {}
ReplicaStatus(const RaftServer &trg, bool onl, LogIndex indx, const std::string &ver = "N/A", int resilvering = -1)
: target(trg), online(onl), logSize(indx), version(ver), resilveringProgress(resilvering) {}
bool upToDate(LogIndex leaderLogSize) const {
if(!online) return false;
......@@ -273,7 +274,10 @@ struct ReplicaStatus {
if(online) {
ss << "| ONLINE | ";
if(upToDate(currentLogSize)) {
if(resilveringProgress >= 0) {
ss << "RESILVERING-PROGRESS " << resilveringProgress << " | ";
}
else if(upToDate(currentLogSize)) {
ss << "UP-TO-DATE | ";
}
else {
......
......@@ -405,10 +405,17 @@ LogIndex RaftReplicaTracker::streamUpdates(RaftTalker &talker, LogIndex firstNex
void RaftReplicaTracker::updateStatus(bool online, LogIndex logSize) {
statusOnline = online;
statusLogSize = logSize;
if(resilverer) {
statusResilveringProgress = resilverer->getProgress();
}
else {
statusResilveringProgress = -1;
}
}
ReplicaStatus RaftReplicaTracker::getStatus() {
return { target, statusOnline, statusLogSize, statusNodeVersion.get() };
return { target, statusOnline, statusLogSize, statusNodeVersion.get(), statusResilveringProgress };
}
void RaftReplicaTracker::sendHeartbeats(ThreadAssistant &assistant) {
......
......@@ -98,6 +98,7 @@ private:
std::atomic<bool> statusOnline {false};
std::atomic<LogIndex> statusLogSize {-1};
Synchronized<std::string> statusNodeVersion {"N/A"};
std::atomic<int> statusResilveringProgress {-1};
RaftJournal &journal;
RaftState &state;
......
......@@ -123,6 +123,7 @@ bool RaftResilverer::copyFile(const std::string &path, const std::string &prefix
err = SSTR("Error when coping " << path << ": " << verifier.err());
}
mFilesSent++;
return verifier.ok();
}
......
......@@ -54,7 +54,12 @@ public:
~RaftResilverer();
ResilveringStatus getStatus();
size_t getProgress() const {
return mFilesSent;
}
private:
std::atomic<size_t> mFilesSent {0};
ShardDirectory &shardDirectory;
RaftServer target;
std::unique_ptr<RaftTrimmingBlock> trimmingBlock;
......
......@@ -112,6 +112,8 @@ TEST_F(Resilvering, manual) {
// Let's drive the resilvering logic of #2 manually.
RaftResilverer resilverer(*shardDirectory(0), myself(2), *contactDetails(), *trimmer(0));
RETRY_ASSERT_EQ(resilverer.getStatus().state, ResilveringState::SUCCEEDED);
ASSERT_GE(resilverer.getProgress(), 4u);
qdb_info("Files copied: " << resilverer.getProgress());
// Ensure the data is there after resilvering.
for(size_t i = 0; i < NENTRIES; i++) {
......
......@@ -150,6 +150,9 @@ TEST(Utils, ReplicaStatus) {
ASSERT_EQ(replica.toString(30000), "localhost:123 | ONLINE | UP-TO-DATE | LOG-SIZE 10 | VERSION N/A");
ASSERT_EQ(replica.toString(30009), "localhost:123 | ONLINE | UP-TO-DATE | LOG-SIZE 10 | VERSION N/A");
ASSERT_EQ(replica.toString(30010), "localhost:123 | ONLINE | LAGGING | LOG-SIZE 10 | VERSION N/A");
replica = ReplicaStatus { RaftServer("localhost", 123), true, 10, "9.9.9", 5 };
ASSERT_EQ(replica.toString(123), "localhost:123 | ONLINE | RESILVERING-PROGRESS 5 | LOG-SIZE 10 | VERSION 9.9.9");
}
TEST(Utils, replication_status) {
......
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