Skip to content

Commit

Permalink
Avoid div 0
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsumner committed Aug 4, 2020
1 parent d6f5748 commit 1a1d34e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/riak_kv_get_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,16 @@ prompt_readrepair(VnodeList, LogRepair) ->
fun(RepairList) ->
SW = os:timestamp(),
RepairCount = length(RepairList),
lager:info("Repairing key_count=~w between ~w",
lager:info("Repairing key_count=~w between ~w",
[RepairCount, VnodeList]),
Pause = max(?MIN_REPAIRPAUSE_MS, ?MIN_REPAIRTIME_MS div RepairCount),
RehashFun =
fun({{B, K}, {_BlueClock, _PinkClock}}) ->
timer:sleep(Pause),
riak_kv_vnode:rehash(VnodeList, B, K)
end,
Pause =
max(?MIN_REPAIRPAUSE_MS,
?MIN_REPAIRTIME_MS div max(1, RepairCount)),
RepairFun =
fun({{B, K}, {_BlueClock, _PinkClock}}) ->
timer:sleep(Pause),
riak_kv_vnode:rehash(VnodeList, B, K)
end,
lists:foreach(FetchFun, RepairList),
lists:foreach(RehashFun, RepairList),
case LogRepair of
Expand Down

0 comments on commit 1a1d34e

Please sign in to comment.