Skip to content

Commit 88185e8

Browse files
authored
[improvement](nereids) improve show frontends so slow issue when we don't enable fqdn mode in fe.conf because of using dns resolve firstly but not ip directly (#62139)
### What problem does this PR solve? improve show frontends so slow issue when we don't enable fqdn mode in fe.conf because of using dns resolve firstly but not ip directly
1 parent 6a2f56a commit 88185e8

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/common/proc/FrontendsProcNode.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -204,35 +204,37 @@ private static boolean isHelperNode(List<HostInfo> helperNodes, Frontend fe) {
204204
}
205205

206206
private static boolean isJoin(List<InetSocketAddress> allFeHosts, Frontend fe) {
207+
String feHost = fe.getHost();
208+
int fePort = fe.getEditLogPort();
207209
for (InetSocketAddress addr : allFeHosts) {
208-
if (fe.getEditLogPort() != addr.getPort()) {
210+
if (fePort != addr.getPort()) {
209211
continue;
210212
}
211-
// if hostname of InetSocketAddress is ip, addr.getHostName() may be not equal to fe.getIp()
212-
// so we need to compare fe.getIp() with address.getHostAddress()
213-
InetAddress address = addr.getAddress();
214-
if (null == address) {
215-
LOG.warn("Failed to get InetAddress {}", addr);
216-
continue;
217-
}
218-
if (fe.getHost().equals(address.getHostAddress())) {
219-
return true;
220-
}
221-
}
222-
223-
// Avoid calling getHostName multiple times, don't remove it
224-
for (InetSocketAddress addr : allFeHosts) {
225-
// Avoid calling getHostName multiple times, don't remove it
226-
if (fe.getEditLogPort() != addr.getPort()) {
227-
continue;
228-
}
229-
// https://bugs.openjdk.org/browse/JDK-8143378#:~:text=getHostName()%3B%20takes%20about%205,millisecond%20on%20JDK%20update%2051
230-
// getHostName sometime has bug, take 5s
231-
String host = addr.getHostName();
232-
if (!Strings.isNullOrEmpty(host)) {
233-
if (host.equals(fe.getHost())) {
213+
if (Config.enable_fqdn_mode) {
214+
String hostName = addr.getHostName();
215+
if (!Strings.isNullOrEmpty(hostName) && hostName.equals(feHost)) {
216+
return true;
217+
}
218+
InetAddress address = addr.getAddress();
219+
if (address != null && feHost.equals(address.getHostAddress())) {
234220
return true;
235221
}
222+
if (address == null && !Strings.isNullOrEmpty(hostName) && hostName.equals(feHost)) {
223+
return true;
224+
}
225+
} else {
226+
InetAddress address = addr.getAddress();
227+
if (address != null) {
228+
String addrIp = address.getHostAddress();
229+
if (feHost.equals(addrIp)) {
230+
return true;
231+
}
232+
} else {
233+
String hostName = addr.getHostName();
234+
if (!Strings.isNullOrEmpty(hostName) && hostName.equals(feHost)) {
235+
return true;
236+
}
237+
}
236238
}
237239
}
238240
return false;

0 commit comments

Comments
 (0)