mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Use in SELECT even shards with zero weight [#CLICKHOUSE-3204].
This commit is contained in:
parent
8fb22b1dcb
commit
692b923b0c
@ -24,7 +24,7 @@ namespace
|
|||||||
{
|
{
|
||||||
|
|
||||||
/// Default shard weight.
|
/// Default shard weight.
|
||||||
static constexpr int default_weight = 1;
|
static constexpr UInt32 default_weight = 1;
|
||||||
|
|
||||||
inline bool isLocal(const Cluster::Address & address)
|
inline bool isLocal(const Cluster::Address & address)
|
||||||
{
|
{
|
||||||
@ -195,8 +195,6 @@ Cluster::Cluster(Poco::Util::AbstractConfiguration & config, const Settings & se
|
|||||||
|
|
||||||
const auto & prefix = config_prefix + key;
|
const auto & prefix = config_prefix + key;
|
||||||
const auto weight = config.getInt(prefix + ".weight", default_weight);
|
const auto weight = config.getInt(prefix + ".weight", default_weight);
|
||||||
if (weight == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
addresses.emplace_back(config, prefix);
|
addresses.emplace_back(config, prefix);
|
||||||
addresses.back().replica_num = 1;
|
addresses.back().replica_num = 1;
|
||||||
@ -225,7 +223,9 @@ Cluster::Cluster(Poco::Util::AbstractConfiguration & config, const Settings & se
|
|||||||
std::move(pools), settings.load_balancing, settings.connections_with_failover_max_tries);
|
std::move(pools), settings.load_balancing, settings.connections_with_failover_max_tries);
|
||||||
}
|
}
|
||||||
|
|
||||||
slot_to_shard.insert(std::end(slot_to_shard), weight, shards_info.size());
|
if (weight)
|
||||||
|
slot_to_shard.insert(std::end(slot_to_shard), weight, shards_info.size());
|
||||||
|
|
||||||
shards_info.push_back(info);
|
shards_info.push_back(info);
|
||||||
}
|
}
|
||||||
else if (startsWith(key, "shard"))
|
else if (startsWith(key, "shard"))
|
||||||
@ -240,9 +240,7 @@ Cluster::Cluster(Poco::Util::AbstractConfiguration & config, const Settings & se
|
|||||||
UInt32 current_replica_num = 1;
|
UInt32 current_replica_num = 1;
|
||||||
|
|
||||||
const auto & partial_prefix = config_prefix + key + ".";
|
const auto & partial_prefix = config_prefix + key + ".";
|
||||||
const auto weight = config.getInt(partial_prefix + ".weight", default_weight);
|
const auto weight = config.getUInt(partial_prefix + ".weight", default_weight);
|
||||||
if (weight == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bool internal_replication = config.getBool(partial_prefix + ".internal_replication", false);
|
bool internal_replication = config.getBool(partial_prefix + ".internal_replication", false);
|
||||||
|
|
||||||
@ -310,7 +308,9 @@ Cluster::Cluster(Poco::Util::AbstractConfiguration & config, const Settings & se
|
|||||||
shard_pool = std::make_shared<ConnectionPoolWithFailover>(
|
shard_pool = std::make_shared<ConnectionPoolWithFailover>(
|
||||||
std::move(replicas), settings.load_balancing, settings.connections_with_failover_max_tries);
|
std::move(replicas), settings.load_balancing, settings.connections_with_failover_max_tries);
|
||||||
|
|
||||||
slot_to_shard.insert(std::end(slot_to_shard), weight, shards_info.size());
|
if (weight)
|
||||||
|
slot_to_shard.insert(std::end(slot_to_shard), weight, shards_info.size());
|
||||||
|
|
||||||
shards_info.push_back({std::move(dir_names), current_shard_num, weight, shard_local_addresses, shard_pool, internal_replication});
|
shards_info.push_back({std::move(dir_names), current_shard_num, weight, shard_local_addresses, shard_pool, internal_replication});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
std::vector<std::string> dir_names;
|
std::vector<std::string> dir_names;
|
||||||
/// Number of the shard, the indexation begins with 1
|
/// Number of the shard, the indexation begins with 1
|
||||||
UInt32 shard_num;
|
UInt32 shard_num;
|
||||||
int weight;
|
UInt32 weight;
|
||||||
Addresses local_addresses;
|
Addresses local_addresses;
|
||||||
ConnectionPoolWithFailoverPtr pool;
|
ConnectionPoolWithFailoverPtr pool;
|
||||||
bool has_internal_replication;
|
bool has_internal_replication;
|
||||||
|
Loading…
Reference in New Issue
Block a user