Skip to content

Commit

Permalink
refactor: Output whole error message with source while retry (#16519)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Sep 25, 2024
1 parent 404d631 commit af0e9ba
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/common/storage/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use opendal::layers::ConcurrentLimitLayer;
use opendal::layers::FastraceLayer;
use opendal::layers::ImmutableIndexLayer;
use opendal::layers::LoggingLayer;
use opendal::layers::RetryInterceptor;
use opendal::layers::RetryLayer;
use opendal::layers::TimeoutLayer;
use opendal::raw::HttpClient;
Expand Down Expand Up @@ -137,7 +138,11 @@ pub fn build_operator<B: Builder>(builder: B) -> Result<Operator> {
timeout_layer
})
// Add retry
.layer(RetryLayer::new().with_jitter())
.layer(
RetryLayer::new()
.with_jitter()
.with_notify(DatabendRetryInterceptor),
)
// Add async backtrace
.layer(AsyncBacktraceLayer)
// Add logging
Expand Down Expand Up @@ -408,6 +413,17 @@ fn new_storage_http_client() -> Result<HttpClient> {
Ok(HttpClient::build(builder)?)
}

pub struct DatabendRetryInterceptor;

impl RetryInterceptor for DatabendRetryInterceptor {
fn intercept(&self, err: &opendal::Error, dur: Duration) {
warn!(
target: "opendal::layers::retry",
"will retry after {:.2}s because: {:?}",
dur.as_secs_f64(), err)
}
}

/// DataOperator is the operator to access persist data services.
///
/// # Notes
Expand Down

0 comments on commit af0e9ba

Please sign in to comment.