mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
Merge pull request #10422 from azat/fallback_to_stale_replicas-over-skip_unavailable_shards
Prefer fallback_to_stale_replicas over skip_unavailable_shards
This commit is contained in:
commit
7065a8ba9c
@ -274,12 +274,7 @@ PoolWithFailoverBase<TNestedPool>::getMany(
|
|||||||
< std::forward_as_tuple(!right.is_up_to_date, right.staleness);
|
< std::forward_as_tuple(!right.is_up_to_date, right.staleness);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (up_to_date_count >= min_entries)
|
if (fallback_to_stale_replicas)
|
||||||
{
|
|
||||||
/// There is enough up-to-date entries.
|
|
||||||
try_results.resize(up_to_date_count);
|
|
||||||
}
|
|
||||||
else if (fallback_to_stale_replicas)
|
|
||||||
{
|
{
|
||||||
/// There is not enough up-to-date entries but we are allowed to return stale entries.
|
/// There is not enough up-to-date entries but we are allowed to return stale entries.
|
||||||
/// Gather all up-to-date ones and least-bad stale ones.
|
/// Gather all up-to-date ones and least-bad stale ones.
|
||||||
@ -287,6 +282,11 @@ PoolWithFailoverBase<TNestedPool>::getMany(
|
|||||||
size_t size = std::min(try_results.size(), max_entries);
|
size_t size = std::min(try_results.size(), max_entries);
|
||||||
try_results.resize(size);
|
try_results.resize(size);
|
||||||
}
|
}
|
||||||
|
else if (up_to_date_count >= min_entries)
|
||||||
|
{
|
||||||
|
/// There is enough up-to-date entries.
|
||||||
|
try_results.resize(up_to_date_count);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw DB::Exception(
|
throw DB::Exception(
|
||||||
"Could not find enough connections to up-to-date replicas. Got: " + std::to_string(up_to_date_count)
|
"Could not find enough connections to up-to-date replicas. Got: " + std::to_string(up_to_date_count)
|
||||||
|
@ -81,6 +81,14 @@ SELECT sum(x) FROM distributed SETTINGS
|
|||||||
max_replica_delay_for_distributed_queries=1
|
max_replica_delay_for_distributed_queries=1
|
||||||
''').strip() == '3'
|
''').strip() == '3'
|
||||||
|
|
||||||
|
# Regression for skip_unavailable_shards in conjunction with skip_unavailable_shards
|
||||||
|
assert instance_with_dist_table.query('''
|
||||||
|
SELECT sum(x) FROM distributed SETTINGS
|
||||||
|
load_balancing='in_order',
|
||||||
|
skip_unavailable_shards=1,
|
||||||
|
max_replica_delay_for_distributed_queries=1
|
||||||
|
''').strip() == '3'
|
||||||
|
|
||||||
# If we forbid stale replicas, the query must fail.
|
# If we forbid stale replicas, the query must fail.
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
print instance_with_dist_table.query('''
|
print instance_with_dist_table.query('''
|
||||||
|
Loading…
Reference in New Issue
Block a user