From 3646521989a20cae2a1576dcc4e0a0a1f06c0464 Mon Sep 17 00:00:00 2001 From: Hung Nguyen Date: Mon, 7 Oct 2024 16:57:12 +0700 Subject: [PATCH] STL-715: Fixing read would block error --- VERSION | 2 +- lib/gooddata/rest/connection.rb | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 1e2e96790..d87ab0265 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.7.73 +3.7.74 diff --git a/lib/gooddata/rest/connection.rb b/lib/gooddata/rest/connection.rb index 9b0260afe..ff215933f 100644 --- a/lib/gooddata/rest/connection.rb +++ b/lib/gooddata/rest/connection.rb @@ -94,7 +94,7 @@ def generate_string(length = ID_LENGTH) # Retry block if exception thrown def retryable(options = {}, &_block) - opts = { :tries => 12, :on => RETRYABLE_ERRORS }.merge(options) + opts = { :tries => 17, :on => RETRYABLE_ERRORS }.merge(options) retry_exception = opts[:on] retries = opts[:tries] @@ -114,21 +114,27 @@ def retryable(options = {}, &_block) if (retries -= 1) > 0 retry else - fail e + process_retry_error(e, retry_time) end rescue RestClient::TooManyRequests, RestClient::ServiceUnavailable, *retry_exception => e - GoodData.logger.warn "#{e.message}, retrying in #{retry_time} seconds" sleep retry_time retry_time *= RETRY_TIME_COEFFICIENT - # 10 requests with 1.5 coefficent should take ~ 3 mins to finish + # Total 10 retry requests with 1.5 coefficent should take ~ 2 mins to finish if (retries -= 1) > 0 retry else - fail e + process_retry_error(e, retry_time) end end yield end + + def process_retry_error(e, retry_time) + error_message = "#{e.message}, retrying in #{retry_time} seconds" + GoodData.logger.warn error_message + GoodData.rest_logger.warn error_message + fail e + end end attr_reader :request_params