From cdb869d2faf3d55cc4d35de595b6a803537de029 Mon Sep 17 00:00:00 2001 From: Hung Nguyen Date: Tue, 1 Apr 2025 17:12:50 +0700 Subject: [PATCH] GRIF-177: Add more retry time for read would block issue --- lib/gooddata/helpers/global_helpers.rb | 2 +- lib/gooddata/rest/connection.rb | 4 ++-- spec/unit/rest/polling_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/gooddata/helpers/global_helpers.rb b/lib/gooddata/helpers/global_helpers.rb index b111241a8..0cfbf6020 100644 --- a/lib/gooddata/helpers/global_helpers.rb +++ b/lib/gooddata/helpers/global_helpers.rb @@ -33,7 +33,7 @@ class DeepMergeableHash < Hash include Hashie::Extensions::DeepMerge end - set_const :GD_MAX_RETRY, (ENV['GD_MAX_RETRY'] && ENV['GD_MAX_RETRY'].to_i) || 12 + set_const :GD_MAX_RETRY, (ENV['GD_MAX_RETRY'] && ENV['GD_MAX_RETRY'].to_i) || 14 AES_256_CBC_CIPHER = 'aes-256-cbc' class << self diff --git a/lib/gooddata/rest/connection.rb b/lib/gooddata/rest/connection.rb index 4a847ab82..be93d4f85 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 => 14, :on => RETRYABLE_ERRORS }.merge(options) retry_exception = opts[:on] retries = opts[:tries] @@ -118,9 +118,9 @@ def retryable(options = {}, &_block) end rescue RestClient::TooManyRequests, RestClient::ServiceUnavailable, *retry_exception => e sleep retry_time - retry_time *= RETRY_TIME_COEFFICIENT # Total 10 retry requests with 1.5 coefficent should take ~ 2 mins to finish if (retries -= 1) > 0 + retry_time *= RETRY_TIME_COEFFICIENT retry else process_retry_error(e, retry_time) diff --git a/spec/unit/rest/polling_spec.rb b/spec/unit/rest/polling_spec.rb index c86761603..0373565d6 100644 --- a/spec/unit/rest/polling_spec.rb +++ b/spec/unit/rest/polling_spec.rb @@ -97,14 +97,14 @@ expect do @client.get('/too_many_reqs') end.to raise_error(RestClient::TooManyRequests) - expect(a_request(:get, "#{@server}/too_many_reqs")).to have_been_made.times(12) + expect(a_request(:get, "#{@server}/too_many_reqs")).to have_been_made.times(14) end it 'should make MAX_REQUESTS when hitting 503' do expect do @client.get('/out_of_service') end.to raise_error(RestClient::ServiceUnavailable) - expect(a_request(:get, "#{@server}/out_of_service")).to have_been_made.times(12) + expect(a_request(:get, "#{@server}/out_of_service")).to have_been_made.times(14) end it 'should make 1 additional request when hitting 500' do