Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix: dassert if shared log is damaged when replica server init #513

Merged
merged 3 commits into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions src/dist/replication/lib/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ void replica_stub::initialize(const replication_options &opts, bool clear /* = f
dassert(lerr == ERR_OK, "restart log service must succeed");
}

bool is_log_complete = true;
for (auto it = rps.begin(); it != rps.end(); ++it) {
auto err = it->second->background_sync_checkpoint();
dassert(err == ERR_OK, "sync checkpoint failed, err = %s", err.to_string());
Expand Down Expand Up @@ -598,30 +597,16 @@ void replica_stub::initialize(const replication_options &opts, bool clear /* = f
smax);

if (err == ERR_OK) {
if (smax != pmax) {
levy5307 marked this conversation as resolved.
Show resolved Hide resolved
derror("%s: some shared log state must be lost, smax(%" PRId64 ") vs pmax(%" PRId64
")",
it->second->name(),
smax,
pmax);
is_log_complete = false;
} else {
// just leave inactive_state_transient as its old value
}
dassert_f(smax == pmax,
"{}: some shared log state must be lost, smax({}) vs pmax({})",
it->second->name(),
smax,
pmax);
} else {
it->second->set_inactive_state_transient(false);
}
}

// we will mark all replicas inactive not transient unless all logs are complete
if (!is_log_complete) {
derror("logs are not complete for some replicas, which means that shared log is truncated, "
"mark all replicas as inactive");
for (auto it = rps.begin(); it != rps.end(); ++it) {
it->second->set_inactive_state_transient(false);
}
}

// gc
if (false == _options.gc_disabled) {
_gc_timer_task = tasking::enqueue_timer(
Expand Down