Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Output whole error message with source while retry #16519

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading