From 07fc53179e56720f8ab4744b0e3c32c55c8a101f Mon Sep 17 00:00:00 2001 From: MonishkaDas Date: Thu, 17 Oct 2024 17:16:40 +0530 Subject: [PATCH] Updated custom_size_based_buffer.rb Added exponential backoff to retries. Removed max_retries. --- .../outputs/kusto/custom_size_based_buffer.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/logstash/outputs/kusto/custom_size_based_buffer.rb b/lib/logstash/outputs/kusto/custom_size_based_buffer.rb index d610efb..1b8b0f6 100644 --- a/lib/logstash/outputs/kusto/custom_size_based_buffer.rb +++ b/lib/logstash/outputs/kusto/custom_size_based_buffer.rb @@ -67,8 +67,7 @@ def buffer_flush(options = {}) end items_flushed = 0 - max_retries = 5 - retries = 0 + backoff_interval = 1 begin outgoing_items = [] @@ -103,14 +102,9 @@ def buffer_flush(options = {}) rescue => e @buffer_config[:logger].error("Flush failed: #{e.message}") @buffer_config[:logger].error(e.backtrace.join("\n")) - retries += 1 - if retries <= max_retries - sleep 1 - retry - else - @buffer_config[:logger].error("Max retries reached. Data loss may occur.") - raise e - end + sleep backoff_interval + backoff_interval = [backoff_interval * 2, 60].min # Exponential backoff with a max interval of 60 seconds + retry end @buffer_state[:last_flush] = Time.now.to_i