Revert extra changed lines

That was the changes that looks OK for the initial patchset version, but
not now, after all review comments.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2024-02-22 17:28:26 +01:00
parent fe613ddd06
commit a19b27bd7c
3 changed files with 11 additions and 11 deletions

View File

@ -95,7 +95,6 @@ void ConnectionEstablisher::run(ConnectionEstablisher::TryResult & result, std::
LOG_TRACE(log, "Server {} has unacceptable replica delay for table {}.{}: {}", result.entry->getDescription(), table_to_check->database, table_to_check->table, delay);
ProfileEvents::increment(ProfileEvents::DistributedConnectionStaleReplica);
return;
}
}
catch (const Exception & e)

View File

@ -62,14 +62,13 @@ public:
/// The same as getMany(), but return std::vector<TryResult>.
std::vector<TryResult> getManyForTableFunction(const ConnectionTimeouts & timeouts,
const Settings & settings,
PoolMode pool_mode);
const Settings & settings, PoolMode pool_mode);
using Base = PoolWithFailoverBase<IConnectionPool>;
using TryResult = Base::TryResult;
/// The same as getMany(), but check that:
/// - replication delay for table_to_check is acceptable (delay threshold is taken from settings)
/// The same as getMany(), but check that replication delay for table_to_check is acceptable.
/// Delay threshold is taken from settings.
std::vector<TryResult> getManyChecked(
const ConnectionTimeouts & timeouts,
const Settings & settings,

View File

@ -293,12 +293,14 @@ PoolWithFailoverBase<TNestedPool>::getMany(
std::erase_if(try_results, [](const TryResult & r) { return r.entry.isNull() || !r.is_usable; });
auto comparator = [&](const TryResult & left, const TryResult & right)
{
return std::forward_as_tuple(!left.is_up_to_date, left.delay)
< std::forward_as_tuple(!right.is_up_to_date, right.delay);
};
std::stable_sort(try_results.begin(), try_results.end(), comparator);
/// Sort so that preferred items are near the beginning.
std::stable_sort(
try_results.begin(), try_results.end(),
[](const TryResult & left, const TryResult & right)
{
return std::forward_as_tuple(!left.is_up_to_date, left.delay)
< std::forward_as_tuple(!right.is_up_to_date, right.delay);
});
if (fallback_to_stale_replicas)
{