Skip to content

Commit

Permalink
Fix wrong calculation of max retry timeout for exponential backoff
Browse files Browse the repository at this point in the history
Exponents should be started with 0, not -1.

Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Feb 22, 2022
1 parent 296f021 commit 00a5cc1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/retry_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def naive_next_time(retry_next_times)
def calc_max_retry_timeout(max_steps)
result = 0
max_steps.times { |i|
result += calc_interval(i)
result += calc_interval(i + 1)
}
result
end
Expand Down
2 changes: 1 addition & 1 deletion test/plugin_helper/test_retry_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class Dummy < Fluent::Plugin::TestBase
override_current_time(s, dummy_current_time)

timeout = 0
5.times { |i| timeout += 1.0 * (2 ** (i - 1)) }
5.times { |i| timeout += 1.0 * (2 ** i) }

assert_equal dummy_current_time, s.current_time
assert_equal (dummy_current_time + 100), s.timeout_at
Expand Down

0 comments on commit 00a5cc1

Please sign in to comment.