Skip to content

Commit

Permalink
Prevent retry.step from being called too many times in a short time
Browse files Browse the repository at this point in the history
This commit resolves fluent#2123
by avoiding the situation when @retry.step is called almost as many
times as the number of flush threads in a short time.
  • Loading branch information
abicky committed Dec 14, 2020
1 parent b039e14 commit fe0b540
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,13 @@ def update_retry_state(chunk_id, using_secondary, error = nil)
log.debug "buffer queue cleared"
@retry = nil
else
@retry.step
# Ensure that the current time is greater than or equal to @retry.next_time to avoid the situation when
# @retry.step is called almost as many times as the number of flush threads in a short time.
if Time.now >= @retry.next_time
@retry.step
else
@retry.recalc_next_time
end
if error
if using_secondary
msg = "failed to flush the buffer with secondary output."
Expand Down
4 changes: 4 additions & 0 deletions lib/fluent/plugin_helper/retry_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def step
nil
end

def recalc_next_time
@next_time = calc_next_time
end

def limit?
if @forever
false
Expand Down

0 comments on commit fe0b540

Please sign in to comment.