Skip to content

Commit

Permalink
Failover for hosts with missing DNS records while connecting to ZooKe…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Sep 24, 2018
1 parent 5c386ea commit 17b8e20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion dbms/src/Common/ZooKeeper/ZooKeeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <Common/StringUtils/StringUtils.h>
#include <Common/PODArray.h>
#include <Common/randomSeed.h>
#include <Common/Exception.h>

#include <Poco/Net/NetException.h>


#define ZOOKEEPER_CONNECTION_TIMEOUT_MS 1000
#define ZOOKEEPER_OPERATION_TIMEOUT_MS 10000
Expand Down Expand Up @@ -58,8 +62,21 @@ void ZooKeeper::init(const std::string & hosts_, const std::string & identity_,
boost::split(addresses_strings, hosts, boost::is_any_of(","));
Coordination::ZooKeeper::Addresses addresses;
addresses.reserve(addresses_strings.size());

for (const auto & address_string : addresses_strings)
addresses.emplace_back(address_string);
{
try
{
addresses.emplace_back(address_string);
}
catch (const Poco::Net::DNSException & e)
{
LOG_ERROR(log, "Cannot use ZooKeeper address " << address_string << ", reason: " << e.displayText());
}
}

if (addresses.empty())
throw KeeperException("Cannot use any of provided ZooKeeper addresses", Coordination::ZBADARGUMENTS);

impl = std::make_unique<Coordination::ZooKeeper>(
addresses,
Expand Down
1 change: 1 addition & 0 deletions dbms/src/Interpreters/DDLWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ void DDLWorker::run()
{
if (!Coordination::isHardwareError(e.code))
throw;
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
catch (...)
Expand Down

0 comments on commit 17b8e20

Please sign in to comment.