Skip to content

Commit

Permalink
Merge pull request #22521 from vbotbuildovich/backport-pr-22327-v24.2…
Browse files Browse the repository at this point in the history
….x-755

[v24.2.x] CORE-5749 retry on dns failure
  • Loading branch information
michael-redpanda authored Jul 26, 2024
2 parents 3470a6b + f8fbf36 commit 132d37a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/v/kafka/client/broker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@
#include "rpc/rpc_utils.h"

#include <seastar/core/coroutine.hh>
#include <seastar/net/dns.hh>

#include <ares.h>

namespace {
bool is_dns_failure_error(const std::system_error& e) {
if (e.code().category() == ss::net::dns::error_category()) {
switch (e.code().value()) {
case ARES_ENOTFOUND:
case ARES_ENODATA:
case ARES_ETIMEOUT:
case ARES_ECONNREFUSED:
return true;
default:
return false;
}
}

return false;
}
} // namespace

namespace kafka::client {

Expand Down Expand Up @@ -50,7 +71,7 @@ ss::future<shared_broker_t> make_broker(
});
})
.handle_exception_type([node_id](const std::system_error& ex) {
if (net::is_reconnect_error(ex)) {
if (net::is_reconnect_error(ex) || is_dns_failure_error(ex)) {
return ss::make_exception_future<shared_broker_t>(
broker_error(node_id, error_code::network_exception));
}
Expand Down
9 changes: 8 additions & 1 deletion src/v/net/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <seastar/core/future.hh>
#include <seastar/net/tls.hh>

#include <system_error>

namespace net {

/**
Expand All @@ -40,7 +42,9 @@ bool is_reconnect_error(const std::system_error& e) {
if (e.code().category() == ss::tls::error_category()) {
return absl::c_any_of(
ss_tls_reconnect_errors, [v](int ec) { return v == ec; });
} else {
} else if (
e.code().category() == std::system_category()
|| e.code().category() == std::generic_category()) {
switch (v) {
case ECONNREFUSED:
case ENETUNREACH:
Expand All @@ -58,6 +62,9 @@ bool is_reconnect_error(const std::system_error& e) {
default:
return false;
}
} else {
// We don't know what the error category is at this point
return false;
}
__builtin_unreachable();
}
Expand Down

0 comments on commit 132d37a

Please sign in to comment.