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

cloud_storage: improve error handling #6524

Merged
merged 2 commits into from
Sep 29, 2022
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
47 changes: 40 additions & 7 deletions src/v/cloud_storage/remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <boost/beast/http/error.hpp>
#include <boost/beast/http/field.hpp>
#include <fmt/chrono.h>
#include <gnutls/gnutls.h>

#include <exception>
#include <utility>
Expand All @@ -47,6 +48,41 @@ enum class error_outcome {
notfound
};

/**
* Identify error cases that should be quickly retried, e.g.
* TCP disconnects, timeouts. Network errors may also show up
* indirectly as errors from the TLS layer.
*/
bool system_error_retryable(const std::system_error& e) {
auto v = e.code().value();

// The name() of seastar's gnutls_error_category class
constexpr std::string_view gnutls_cateogry_name{"GnuTLS"};

if (e.code().category().name() == gnutls_cateogry_name) {
Comment on lines +59 to +62
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder why seastar didn't put this in a header so we could check the category without string comparison 😢

switch (v) {
case GNUTLS_E_PUSH_ERROR:
case GNUTLS_E_PULL_ERROR:
case GNUTLS_E_PREMATURE_TERMINATION:
return true;
default:
return false;
}
} else {
switch (v) {
case ECONNREFUSED:
case ENETUNREACH:
case ETIMEDOUT:
case ECONNRESET:
case EPIPE:
return true;
default:
return false;
}
}
__builtin_unreachable();
}

/// @brief Analyze exception
/// @return error outcome - retry, fail (with exception), or notfound (can only
/// be used with download)
Expand Down Expand Up @@ -107,17 +143,14 @@ static error_outcome categorize_error(
// - any filesystem error
// - broken-pipe
// - any other network error (no memory, bad socket, etc)
if (auto code = cerr.code();
code.value() != ECONNREFUSED && code.value() != ENETUNREACH
&& code.value() != ETIMEDOUT && code.value() != ECONNRESET
&& code.value() != EPIPE) {
vlog(ctxlog.error, "System error {}", cerr);
result = error_outcome::fail;
} else {
if (system_error_retryable(cerr)) {
vlog(
ctxlog.warn,
"System error susceptible for retry {}",
cerr.what());
} else {
vlog(ctxlog.error, "System error {}", cerr);
result = error_outcome::fail;
}
} catch (const ss::timed_out_error& terr) {
// This should happen when the connection pool was disconnected
Expand Down