mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
da8f67123f
allow using expired values while the source of a cache dictionary doesn't respond; clone the source after an error to reset connections; don't ask the source for a little time after error; show the last exception in system.dictionaries for a cache dictionary too.
29 lines
958 B
C++
29 lines
958 B
C++
#include <Interpreters/IExternalLoadable.h>
|
|
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
#include <cmath>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
ExternalLoadableLifetime::ExternalLoadableLifetime(const Poco::Util::AbstractConfiguration & config,
|
|
const std::string & config_prefix)
|
|
{
|
|
const auto & lifetime_min_key = config_prefix + ".min";
|
|
const auto has_min = config.has(lifetime_min_key);
|
|
|
|
min_sec = has_min ? config.getUInt64(lifetime_min_key) : config.getUInt64(config_prefix);
|
|
max_sec = has_min ? config.getUInt64(config_prefix + ".max") : min_sec;
|
|
}
|
|
|
|
|
|
UInt64 ExternalLoadableBackoff::calculateDuration(pcg64 & rnd_engine, size_t error_count) const
|
|
{
|
|
if (error_count < 1)
|
|
error_count = 1;
|
|
std::uniform_int_distribution<UInt64> distribution(0, static_cast<UInt64>(std::exp2(error_count - 1)));
|
|
return std::min<UInt64>(backoff_max_sec, backoff_initial_sec + distribution(rnd_engine));
|
|
}
|
|
|
|
}
|