mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
dbms: Server: queries with several replicas: development [#METR-14410]
This commit is contained in:
parent
98e91a1c32
commit
c3ccfdfa0d
@ -1,18 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <DB/Client/Connection.h>
|
||||
#include <DB/Client/ConnectionPool.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class IConnectionPool;
|
||||
|
||||
/**
|
||||
* Множество реплик одного шарда.
|
||||
*/
|
||||
class ShardReplicas final
|
||||
{
|
||||
public:
|
||||
ShardReplicas(IConnectionPool * pool_, Settings * settings_);
|
||||
ShardReplicas(std::vector<ConnectionPool::Entry> & entries, Settings * settings_);
|
||||
|
||||
~ShardReplicas() = default;
|
||||
|
||||
|
@ -156,8 +156,16 @@ protected:
|
||||
{
|
||||
if (use_many_replicas)
|
||||
{
|
||||
shard_replicas.reset(new ShardReplicas(pool, &settings));
|
||||
shard_replicas->sendQuery(query, "", stage, &settings, true);
|
||||
auto entries = pool->getMany(&settings);
|
||||
if (entries.size() > 1)
|
||||
shard_replicas.reset(new ShardReplicas(entries, &settings));
|
||||
else if (entries.size() == 1)
|
||||
{
|
||||
use_many_replicas = false;
|
||||
connection = &*entries[0];
|
||||
}
|
||||
else // XXX Придумать исключение + сообщение
|
||||
throw Exception("");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -167,10 +175,13 @@ protected:
|
||||
pool_entry = pool->get(send_settings ? &settings : nullptr);
|
||||
connection = &*pool_entry;
|
||||
}
|
||||
|
||||
connection->sendQuery(query, "", stage, send_settings ? &settings : nullptr, true);
|
||||
}
|
||||
|
||||
if (use_many_replicas)
|
||||
shard_replicas->sendQuery(query, "", stage, &settings, true);
|
||||
else
|
||||
connection->sendQuery(query, "", stage, send_settings ? &settings : nullptr, true);
|
||||
|
||||
sendExternalTables();
|
||||
sent_query = true;
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
#include <DB/Client/ShardReplicas.h>
|
||||
#include <DB/Client/ConnectionPool.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
ShardReplicas::ShardReplicas(IConnectionPool * pool_, Settings * settings_) :
|
||||
ShardReplicas::ShardReplicas(std::vector<ConnectionPool::Entry> & entries, Settings * settings_) :
|
||||
settings(settings_)
|
||||
{
|
||||
auto entries = pool_->getMany(settings);
|
||||
valid_replicas_count = entries.size();
|
||||
replica_hash.reserve(valid_replicas_count);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user