Skip to content

Commit

Permalink
Fix wrong max retry timeout for exponential backoff again
Browse files Browse the repository at this point in the history
The patch in #3640 was still wrong, the expected one is

  c + c * b^1 + (...) + c*b^k

but the patch was

  c + c * b^1 + (...) + c*b^(k-1)

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
  • Loading branch information
ashie committed Mar 22, 2022
1 parent 6927305 commit d5bfb01
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
Expand Up @@ -158,7 +158,7 @@ def naive_next_time(retry_next_times)

def calc_max_retry_timeout(max_steps)
result = 0
max_steps.times { |i|
(0..max_steps).each { |i|
result += calc_interval(i + 1)
}
result
Expand Down
2 changes: 1 addition & 1 deletion test/plugin_helper/test_retry_state.rb
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) }
(0..5).each { |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 d5bfb01

Please sign in to comment.