@@ -84,6 +84,7 @@ namespace S3
8484
8585Client::RetryStrategy::RetryStrategy (const PocoHTTPClientConfiguration::RetryStrategy & config_)
8686 : config(config_)
87+ , log(getLogger(" S3ClientRetryStrategy" ))
8788{
8889 chassert (config.max_delay_ms <= (1.0 + config.jitter_factor ) * config.initial_delay_ms * (1ul << 31l ));
8990 chassert (config.jitter_factor >= 0 && config.jitter_factor <= 1 );
@@ -133,7 +134,7 @@ long Client::RetryStrategy::CalculateDelayBeforeNextRetry(const Aws::Client::AWS
133134 else
134135 res = std::min<uint64_t >(config.initial_delay_ms * backoffLimitedPow, config.max_delay_ms );
135136
136- LOG_TEST (getLogger ( " RetryStrategy " ) , " Next retry in {} ms" , res);
137+ LOG_TEST (log , " Next retry in {} ms" , res);
137138 return res;
138139}
139140
@@ -143,6 +144,37 @@ long Client::RetryStrategy::GetMaxAttempts() const
143144 return config.max_retries + 1 ;
144145}
145146
147+ void Client::RetryStrategy::RequestBookkeeping (const Aws::Client::HttpResponseOutcome & httpResponseOutcome)
148+ {
149+ if (!httpResponseOutcome.IsSuccess ())
150+ {
151+ const auto & error = httpResponseOutcome.GetError ();
152+ if (error.ShouldRetry ())
153+ LOG_TRACE (
154+ log,
155+ " Attempt {}/{} failed with retryable error: {}, {}" ,
156+ httpResponseOutcome.GetRetryCount () + 1 ,
157+ GetMaxAttempts (),
158+ static_cast <size_t >(error.GetResponseCode ()),
159+ error.GetMessage ());
160+ }
161+ }
162+
163+ void Client::RetryStrategy::RequestBookkeeping (
164+ const Aws::Client::HttpResponseOutcome & httpResponseOutcome, const Aws::Client::AWSError<Aws::Client::CoreErrors> & lastError)
165+ {
166+ if (httpResponseOutcome.IsSuccess ())
167+ LOG_TRACE (
168+ log,
169+ " Attempt {}/{} succeeded with response code {}, last error: {}, {}" ,
170+ httpResponseOutcome.GetRetryCount () + 1 ,
171+ GetMaxAttempts (),
172+ static_cast <size_t >(httpResponseOutcome.GetResult ()->GetResponseCode ()),
173+ static_cast <size_t >(lastError.GetResponseCode ()),
174+ lastError.GetMessage ());
175+ RequestBookkeeping (httpResponseOutcome);
176+ }
177+
146178namespace
147179{
148180
@@ -254,15 +286,27 @@ Client::Client(
254286
255287 LOG_TRACE (log, " API mode of the S3 client: {}" , api_mode);
256288
257- LOG_TRACE (
258- log,
259- " Slowing down threads on retryable errors is {}" ,
260- client_configuration.s3_slow_all_threads_after_retryable_error ? " enabled" : " disabled" );
261-
262- LOG_TRACE (
263- log,
264- " Slowing down threads on network errors is {}" ,
265- client_configuration.s3_slow_all_threads_after_network_error ? " enabled" : " disabled" );
289+ if (client_configuration.for_disk_s3 )
290+ {
291+ LOG_TRACE (
292+ log,
293+ " S3 client for disk '{}' initialized with s3_retry_attempts: {}" ,
294+ client_configuration.opt_disk_name .value_or (" " ),
295+ client_configuration.retry_strategy .max_retries );
296+ LOG_TRACE (
297+ log,
298+ " S3 client for disk '{}': slowing down threads on retryable errors is {}" ,
299+ client_configuration.opt_disk_name .value_or (" " ),
300+ client_configuration.s3_slow_all_threads_after_retryable_error ? " enabled" : " disabled" );
301+ }
302+ else
303+ {
304+ LOG_TRACE (log, " S3 client initialized with s3_retry_attempts: {}" , client_configuration.retry_strategy .max_retries );
305+ LOG_TRACE (
306+ log,
307+ " S3 client: slowing down threads on retryable errors is {}" ,
308+ client_configuration.s3_slow_all_threads_after_retryable_error ? " enabled" : " disabled" );
309+ }
266310
267311 detect_region = provider_type == ProviderType::AWS && explicit_region == Aws::Region::AWS_GLOBAL;
268312
@@ -1143,6 +1187,7 @@ PocoHTTPClientConfiguration ClientFactory::createClientConfiguration( // NOLINT
11431187 bool s3_slow_all_threads_after_retryable_error,
11441188 bool enable_s3_requests_logging,
11451189 bool for_disk_s3,
1190+ std::optional<std::string> opt_disk_name,
11461191 const ThrottlerPtr & get_request_throttler,
11471192 const ThrottlerPtr & put_request_throttler,
11481193 const String & protocol)
@@ -1164,6 +1209,7 @@ PocoHTTPClientConfiguration ClientFactory::createClientConfiguration( // NOLINT
11641209 s3_slow_all_threads_after_retryable_error,
11651210 enable_s3_requests_logging,
11661211 for_disk_s3,
1212+ opt_disk_name,
11671213 context->getGlobalContext ()->getSettingsRef ()[Setting::s3_use_adaptive_timeouts],
11681214 get_request_throttler,
11691215 put_request_throttler,
0 commit comments