mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Add requested changes. [#CLICKHOUSE-3645]
This commit is contained in:
parent
8746149965
commit
864dc0546b
@ -25,6 +25,36 @@ namespace ErrorCodes
|
||||
}
|
||||
|
||||
|
||||
/// Call it inside catch section
|
||||
/// Returns true if it is a network error
|
||||
static bool isNetworkError()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
if (e.code() == ErrorCodes::TIMEOUT_EXCEEDED || e.code() == ErrorCodes::ALL_CONNECTION_TRIES_FAILED)
|
||||
return true;
|
||||
}
|
||||
catch (Poco::Net::DNSException & e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (Poco::TimeoutException & e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
/// Do nothing
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DNSCacheUpdater::DNSCacheUpdater(Context & context_)
|
||||
: context(context_), pool(context_.getBackgroundPool())
|
||||
{
|
||||
@ -73,7 +103,7 @@ DNSCacheUpdater::~DNSCacheUpdater()
|
||||
}
|
||||
|
||||
|
||||
bool DNSCacheUpdater::incrementNetworkErrors()
|
||||
bool DNSCacheUpdater::incrementNetworkErrorEventsIfNeeded()
|
||||
{
|
||||
if (isNetworkError())
|
||||
{
|
||||
@ -84,33 +114,5 @@ bool DNSCacheUpdater::incrementNetworkErrors()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DNSCacheUpdater::isNetworkError()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
if (e.code() == ErrorCodes::TIMEOUT_EXCEEDED || e.code() == ErrorCodes::ALL_CONNECTION_TRIES_FAILED)
|
||||
return true;
|
||||
}
|
||||
catch (Poco::Net::DNSException & e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (Poco::TimeoutException & e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
/// Do nothing
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,15 +15,11 @@ class DNSCacheUpdater
|
||||
{
|
||||
public:
|
||||
|
||||
DNSCacheUpdater(Context & context);
|
||||
explicit DNSCacheUpdater(Context & context);
|
||||
~DNSCacheUpdater();
|
||||
|
||||
/// Call it inside catch section
|
||||
/// Returns true if it is a network error
|
||||
static bool isNetworkError();
|
||||
|
||||
/// Checks if it is a network error and increments ProfileEvents::NetworkErrors
|
||||
static bool incrementNetworkErrors();
|
||||
static bool incrementNetworkErrorEventsIfNeeded();
|
||||
|
||||
private:
|
||||
bool run();
|
||||
|
@ -378,7 +378,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
|
||||
if (!internal)
|
||||
onExceptionBeforeStart(query, context, current_time);
|
||||
|
||||
DNSCacheUpdater::incrementNetworkErrors();
|
||||
DNSCacheUpdater::incrementNetworkErrorEventsIfNeeded();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ void BackgroundProcessingPool::threadFunction()
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
DNSCacheUpdater::incrementNetworkErrors();
|
||||
DNSCacheUpdater::incrementNetworkErrorEventsIfNeeded();
|
||||
}
|
||||
|
||||
if (shutdown)
|
||||
|
Loading…
Reference in New Issue
Block a user