Skip to content

Commit c5efc93

Browse files
Backport #553 (66de28e) for 2.15.x
1 parent b29dbf6 commit c5efc93

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ra_server.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,8 @@ handle_follower(#append_entries_rpc{term = Term,
11091109
" including ~b entries did not validate local log. "
11101110
"Local last index ~b",
11111111
[LogId, PLIdx, length(Entries0), LocalLastIdx]),
1112-
{LVTerm, State2} = fetch_term(LastValidatedIdx, State0),
1112+
{LVTerm, State2} = fetch_term(LastValidatedIdx,
1113+
State0#{log => Log2}),
11131114
Reply = #append_entries_reply{term = CurTerm,
11141115
success = true,
11151116
next_index = LastValidatedIdx + 1,
@@ -1162,7 +1163,8 @@ handle_follower(#append_entries_rpc{term = Term,
11621163
transition_to => follower}}},
11631164
Effects};
11641165
{term_mismatch, OtherTerm, Log0} ->
1165-
LastApplied = maps:get(last_applied, State00),
1166+
State1 = State0#{log => Log0},
1167+
LastApplied = maps:get(last_applied, State1),
11661168
?INFO("~ts: term mismatch - follower had entry at ~b with term ~b "
11671169
"but not with term ~b~n"
11681170
"Asking leader ~w to resend from ~b",
@@ -1177,11 +1179,10 @@ handle_follower(#append_entries_rpc{term = Term,
11771179
% This _may_ overwrite some valid entries but is probably the
11781180
% simplest and most reliable way to proceed
11791181
{Reply, State2} = mismatch_append_entries_reply(Term, LastApplied,
1180-
State0),
1182+
State1),
11811183
Effects = [cast_reply(Id, LeaderId, Reply) | Effects0],
11821184
{await_condition,
1183-
State2#{log => Log0,
1184-
condition =>
1185+
State2#{condition =>
11851186
#{predicate_fun => follower_catchup_cond_fun(term_mismatch),
11861187
% repeat reply effect on condition timeout
11871188
timeout => #{effects => Effects,

0 commit comments

Comments
 (0)