@@ -444,11 +444,11 @@ recover(#{cfg := #cfg{log_id = LogId,
444
444
{#{log := Log0 ,
445
445
cfg := # cfg {effective_machine_version = EffMacVerAfter }} = State1 , _ } =
446
446
apply_to (CommitIndex ,
447
- fun ({Idx , _ , _ } = E , S0 ) ->
447
+ fun ({_Idx , _ , _ } = E , S0 ) ->
448
448
% % Clear out the effects and notifies map
449
449
% % to avoid memory explosion
450
450
{Mod , LastAppl , S , MacSt , _E , _N , LastTs } = apply_with (E , S0 ),
451
- put_counter (Cfg , ? C_RA_SVR_METRIC_LAST_APPLIED , Idx ),
451
+ put_counter (Cfg , ? C_RA_SVR_METRIC_LAST_APPLIED , LastAppl ),
452
452
{Mod , LastAppl , S , MacSt , [], #{}, LastTs }
453
453
end ,
454
454
State0 , []),
@@ -1582,10 +1582,13 @@ handle_receive_snapshot(#install_snapshot_rpc{term = Term,
1582
1582
% % are of the right term
1583
1583
{LastIdx , _ } = ra_log :last_index_term (Log00 ),
1584
1584
{Log , _ } = lists :foldl (
1585
- fun ({I , _ , _ } = E , {L0 , LstIdx }) ->
1586
- {ok , L } = ra_log :write_sparse (E , LstIdx , L0 ),
1587
- {L , I }
1588
- end , {Log00 , LastIdx }, ChunkOrEntries ),
1585
+ fun ({I , _ , _ } = E , {L0 , LstIdx }) when I > LastApplied ->
1586
+ {ok , L } = ra_log :write_sparse (E , LstIdx , L0 ),
1587
+ {L , I };
1588
+ (_ , Acc ) ->
1589
+ % % drop any entries that are lower than last applied
1590
+ Acc
1591
+ end , {Log00 , LastIdx }, ChunkOrEntries ),
1589
1592
State = update_term (Term , State0 #{log => Log ,
1590
1593
snapshot_phase => pre }),
1591
1594
{receive_snapshot , State , [{reply , Reply }]};
0 commit comments