Skip to content

Commit

Permalink
eff
Browse files Browse the repository at this point in the history
  • Loading branch information
kjnilsson committed May 24, 2024
1 parent acd158e commit 3054454
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/ra_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,19 @@ handle_event({snapshot_written, {SnapIdx, _} = Snap, SnapKind},
CPEffects = [{delete_snapshot,
ra_snapshot:directory(SnapState, checkpoint),
Checkpoint} || Checkpoint <- Checkpoints],
Effects = [DeleteCurrentSnap | CPEffects] ++ Effects0,
Effects1 = [DeleteCurrentSnap | CPEffects] ++ Effects0,
%% do not set last written index here as the snapshot may
%% be for a past index
LWIdxTerm = case LastWrittenIdx > SnapIdx of
true ->
LWIdx;
false ->
Snap
end,
{LWIdxTerm, Effects} =
case LastWrittenIdx > SnapIdx of
true ->
{LWIdx, Effects1};
false ->
{Snap,
[{next_event,
{ra_log_event,
{truncate_cache, LastWrittenIdx, SnapIdx}}} | Effects1]}
end,

{State#?MODULE{first_index = SnapIdx + 1,
last_index = max(LstIdx, SnapIdx),
Expand Down

0 comments on commit 3054454

Please sign in to comment.