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

[fix](brpc_client_cache) resolve hostname in DNS cache before passing to brpc (#40074) #40786

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

kaijchen
Copy link
Contributor

backport #40074

… to brpc (apache#40074)

Currently brpc does not support resloving IPv6 hostnames, errors will be
returned on `brpc::Channel::Init`.
The brpc client cache may return `nullptr` on its `get_client` or
`get_new_client_no_cache` APIs.

This PR made the following changes:

1. Resolve hostnames from DNS cache before passing it to brpc.
2. Callers should check nullptr after get client, in case of failures.
@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@kaijchen
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

if (!is_valid_ip(host)) {
Status status = ExecEnv::GetInstance()->dns_cache()->get(host, &realhost);
std::string realhost = host;
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'auto dns_cache' can be declared as 'auto *dns_cache' [readability-qualified-auto]

Suggested change
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
auto *dns_cache = ExecEnv::GetInstance()->dns_cache();

@@ -71,11 +71,26 @@ Status transmit_block_httpv2(ExecEnv* exec_env, std::unique_ptr<Closure> closure
TNetworkAddress brpc_dest_addr) {
RETURN_IF_ERROR(request_embed_attachment_contain_blockv2(closure->request_.get(), closure));

std::string host = brpc_dest_addr.hostname;
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'auto dns_cache' can be declared as 'auto *dns_cache' [readability-qualified-auto]

Suggested change
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
auto *dns_cache = ExecEnv::GetInstance()->dns_cache();

@@ -700,11 +700,30 @@ void VNodeChannel::try_send_pending_block(RuntimeState* state) {
return;
}

std::string host = _node_info.host;
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'auto dns_cache' can be declared as 'auto *dns_cache' [readability-qualified-auto]

Suggested change
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
auto *dns_cache = ExecEnv::GetInstance()->dns_cache();

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.15% (9318/25778)
Line Coverage: 27.71% (76485/276002)
Region Coverage: 26.48% (39264/148250)
Branch Coverage: 23.32% (20033/85906)
Coverage Report: http://coverage.selectdb-in.cc/coverage/cc9d32d6d823023cc307e99dab7319fef098972b_cc9d32d6d823023cc307e99dab7319fef098972b/report/index.html

@yiguolei yiguolei merged commit 7851563 into apache:branch-2.1 Sep 13, 2024
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants