Skip to content

Commit

Permalink
fix: dassert if shared log is damaged when replica server init (XiaoM…
Browse files Browse the repository at this point in the history
  • Loading branch information
foreverneverer authored Jun 24, 2020
1 parent ed267e2 commit c7bfaa7
Showing 1 changed file with 5 additions and 20 deletions.
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) {
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

0 comments on commit c7bfaa7

Please sign in to comment.