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

[v24.2.x] CORE-5749 retry on dns failure #22521

Merged
Show file tree
Hide file tree
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
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
Loading