@@ -1109,7 +1109,8 @@ handle_follower(#append_entries_rpc{term = Term,
1109
1109
" including ~b entries did not validate local log. "
1110
1110
" Local last index ~b " ,
1111
1111
[LogId , PLIdx , length (Entries0 ), LocalLastIdx ]),
1112
- {LVTerm , State2 } = fetch_term (LastValidatedIdx , State0 ),
1112
+ {LVTerm , State2 } = fetch_term (LastValidatedIdx ,
1113
+ State0 #{log => Log2 }),
1113
1114
Reply = # append_entries_reply {term = CurTerm ,
1114
1115
success = true ,
1115
1116
next_index = LastValidatedIdx + 1 ,
@@ -1162,7 +1163,8 @@ handle_follower(#append_entries_rpc{term = Term,
1162
1163
transition_to => follower }}},
1163
1164
Effects };
1164
1165
{term_mismatch , OtherTerm , Log0 } ->
1165
- LastApplied = maps :get (last_applied , State00 ),
1166
+ State1 = State0 #{log => Log0 },
1167
+ LastApplied = maps :get (last_applied , State1 ),
1166
1168
? INFO (" ~ts : term mismatch - follower had entry at ~b with term ~b "
1167
1169
" but not with term ~b~n "
1168
1170
" Asking leader ~w to resend from ~b " ,
@@ -1177,11 +1179,10 @@ handle_follower(#append_entries_rpc{term = Term,
1177
1179
% This _may_ overwrite some valid entries but is probably the
1178
1180
% simplest and most reliable way to proceed
1179
1181
{Reply , State2 } = mismatch_append_entries_reply (Term , LastApplied ,
1180
- State0 ),
1182
+ State1 ),
1181
1183
Effects = [cast_reply (Id , LeaderId , Reply ) | Effects0 ],
1182
1184
{await_condition ,
1183
- State2 #{log => Log0 ,
1184
- condition =>
1185
+ State2 #{condition =>
1185
1186
#{predicate_fun => follower_catchup_cond_fun (term_mismatch ),
1186
1187
% repeat reply effect on condition timeout
1187
1188
timeout => #{effects => Effects ,
0 commit comments