Commit 77fb6117 authored by Li Wei's avatar Li Wei Committed by Willem Thiart
Browse files

DAOS-333 server: Don't remove later entries for matching AEs



If an AE request's previous entry matches the follower's, then the
follower doesn't need to truncate its log at prev_log_idx. When the
follower checks if the other entries in the AE request are consistent
with its local ones, it already takes care of truncating at any
inconsistency. If any later entries not covered by this AE request are
inconsistent, future AE requests shall truncate them.
Signed-off-by: default avatarLi Wei <wei.g.li@intel.com>
parent e33da84a
...@@ -395,21 +395,11 @@ int raft_recv_appendentries( ...@@ -395,21 +395,11 @@ int raft_recv_appendentries(
} }
} }
r->current_idx = ae->prev_log_idx;
/* 3. If an existing entry conflicts with a new one (same index /* 3. If an existing entry conflicts with a new one (same index
but different terms), delete the existing entry and all that but different terms), delete the existing entry and all that
follow it (§5.3) */ follow it (§5.3) */
if (0 < ae->prev_log_idx && ae->prev_log_idx + 1 < raft_get_current_idx(me_))
{
/* Heartbeats shouldn't cause logs to be deleted. Heartbeats might be
* sent before the leader received the last appendentries response */
if (ae->n_entries != 0 &&
/* this is an old out-of-order appendentry message */
me->commit_idx < ae->prev_log_idx + 1)
raft_delete_entry_from_idx(me_, ae->prev_log_idx + 1);
}
r->current_idx = ae->prev_log_idx;
int i; int i;
for (i = 0; i < ae->n_entries; i++) for (i = 0; i < ae->n_entries; i++)
{ {
......
...@@ -1337,7 +1337,7 @@ void TestRaft_follower_recv_appendentries_delete_entries_if_conflict_with_new_en ...@@ -1337,7 +1337,7 @@ void TestRaft_follower_recv_appendentries_delete_entries_if_conflict_with_new_en
CuAssertTrue(tc, !strncmp(ety_appended->data.buf, str4, 3)); CuAssertTrue(tc, !strncmp(ety_appended->data.buf, str4, 3));
} }
void TestRaft_follower_recv_appendentries_delete_entries_if_current_idx_greater_than_prev_log_idx( void TestRaft_follower_recv_appendentries_delete_entries_if_conflict_with_new_entries_greater_than_prev_log_idx(
CuTest * tc) CuTest * tc)
{ {
raft_cbs_t funcs = { raft_cbs_t funcs = {
......
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