diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/FQDNManager.java b/fe/fe-core/src/main/java/org/apache/doris/system/FQDNManager.java index 2f60d3b2b5ec99..e86e2b76a46cd0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/system/FQDNManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/system/FQDNManager.java @@ -34,6 +34,8 @@ public class FQDNManager extends MasterDaemon { private static final Logger LOG = LogManager.getLogger(FQDNManager.class); + public static final String UNKNOWN_HOST_IP = "unknown"; + private SystemInfoService nodeMgr; public FQDNManager(SystemInfoService nodeMgr) { @@ -64,6 +66,13 @@ private void updateFeIp() { } } catch (UnknownHostException e) { LOG.warn("unknown host name for fe, {}", fe.getHostName(), e); + // add fe alive check to make ip work when fe is still alive and dns has some problem. + if (!fe.isAlive() && !fe.getIp().equalsIgnoreCase(UNKNOWN_HOST_IP)) { + String ip = fe.getIp(); + fe.setIp(UNKNOWN_HOST_IP); + Env.getCurrentEnv().getEditLog().logModifyFrontend(fe); + LOG.warn("ip for {} of fe has been changed from {} to {}", fe.getHostName(), ip, "unknown"); + } } catch (DdlException e) { LOG.warn("fail to update ip for fe, {}", fe.getHostName(), e); } @@ -85,6 +94,14 @@ private void updateBeIp() { } } catch (UnknownHostException e) { LOG.warn("unknown host name for be, {}", be.getHostName(), e); + // add be alive check to make ip work when be is still alive and dns has some problem. + if (!be.isAlive() && !be.getIp().equalsIgnoreCase(UNKNOWN_HOST_IP)) { + String ip = be.getIp(); + ClientPool.backendPool.clearPool(new TNetworkAddress(ip, be.getBePort())); + be.setIp(UNKNOWN_HOST_IP); + Env.getCurrentEnv().getEditLog().logBackendStateChange(be); + LOG.warn("ip for {} of be has been changed from {} to {}", be.getHostName(), ip, "unknown"); + } } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java b/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java index abb08dcb961d08..1b10fd28334257 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java +++ b/fe/fe-core/src/main/java/org/apache/doris/system/SystemInfoService.java @@ -192,10 +192,6 @@ public void addBackends(List hostInfos, boolean isFree) public void addBackends(List hostInfos, boolean isFree, String destCluster, Map tagMap) throws UserException { for (HostInfo hostInfo : hostInfos) { - //if not enable_fqdn,ignore hostName - if (!Config.enable_fqdn_mode) { - hostInfo.setHostName(null); - } if (Config.enable_fqdn_mode && StringUtils.isEmpty(hostInfo.getHostName())) { throw new DdlException("backend's hostName should not be empty while enable_fqdn_mode is true"); }