mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Added some explanations on randomization
This commit is contained in:
parent
acb5fb8179
commit
0296d7d026
@ -10,7 +10,7 @@ static bool startsWith(const std::string & s, const char * prefix)
|
||||
return s.size() >= strlen(prefix) && 0 == memcmp(s.data(), prefix, strlen(prefix));
|
||||
}
|
||||
|
||||
/// This is thread-safe
|
||||
/// This reads from "/dev/urandom" and thus is thread-safe
|
||||
std::random_device rd;
|
||||
|
||||
using namespace mysqlxx;
|
||||
@ -39,6 +39,11 @@ PoolWithFailover::PoolWithFailover(const Poco::Util::AbstractConfiguration & con
|
||||
}
|
||||
}
|
||||
|
||||
/// PoolWithFailover objects are stored in a cache inside PoolFactory.
|
||||
/// This cache is reset by ExternalDictionariesLoader after every SYSTEM RELOAD DICTIONAR{Y|IES}
|
||||
/// which triggers massive re-constructing of connection pools.
|
||||
/// The state of PRNDGs like std::mt19937 is considered to be quite heavy
|
||||
/// thus here we attempt to optimize its construction.
|
||||
static thread_local std::mt19937 rnd_generator(rd());
|
||||
for (auto & [_, replicas] : replicas_by_priority)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user