Skip to content

Commit 83254a4

Browse files
committed
Only schedule retention eval if there are multiple segments remaining
1 parent 4139d63 commit 83254a4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/osiris_retention.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ code_change(_OldVsn, State, _Extra) ->
8888
%%%===================================================================
8989
%%% Internal functions
9090
%%%===================================================================
91-
schedule({eval, Name, _Dir, Specs, _Fun} = Eval, _Result,
91+
schedule({eval, Name, _Dir, Specs, _Fun} = Eval,
92+
{_, _, NumSegmentRemaining},
9293
#state{scheduled = Scheduled0} = State) ->
9394
%% we need to check the scheduled map even if the current specs do not
9495
%% include max_age as the retention config could have changed
@@ -99,9 +100,9 @@ schedule({eval, Name, _Dir, Specs, _Fun} = Eval, _Result,
99100
error ->
100101
Scheduled0
101102
end,
102-
case lists:any(fun ({T, _}) -> T == max_age end, Specs) of
103+
case lists:any(fun ({T, _}) -> T == max_age end, Specs) andalso
104+
NumSegmentRemaining > 1 of
103105
true ->
104-
%% schedule a new eval
105106
EvalInterval = application:get_env(osiris, retention_eval_interval,
106107
?DEFAULT_SHEDULED_EVAL_TIME),
107108
Ref = erlang:send_after(EvalInterval, self(), {'$gen_cast', Eval}),

0 commit comments

Comments
 (0)