From 86af533e83b7dbb1b8df9c756e1cb1dbf000dcab Mon Sep 17 00:00:00 2001 From: Xiangyu Wang Date: Wed, 28 Jun 2023 23:12:06 +0800 Subject: [PATCH] [Enhancement](heartbeat) make heartbeat ok when config repeated host-ip pairs (#21228) --- be/src/util/network_util.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/be/src/util/network_util.cpp b/be/src/util/network_util.cpp index 20695bbfba..6841e257a3 100644 --- a/be/src/util/network_util.cpp +++ b/be/src/util/network_util.cpp @@ -96,7 +96,15 @@ Status hostname_to_ip_addrs(const std::string& name, std::vector* a return Status::InternalError("Could not convert IPv4 address for: {}", name); } - addresses->push_back(std::string(addr_buf)); + // add address if not exists + std::string address = std::string(addr_buf); + if (std::find(addresses->begin(), addresses->end(), address) != addresses->end()) { + LOG(WARNING) << "Repeated ip addresses has been found for host: " << name + << ", ip address:" << address + << ", please check your network configuration"; + } else { + addresses->push_back(address); + } it = it->ai_next; }