mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
dbms: Server: queries with several replicas: development [#METR-14410]
This commit is contained in:
parent
c43c758618
commit
f6b20383c4
@ -182,27 +182,11 @@ protected:
|
|||||||
|
|
||||||
case Protocol::Server::Exception:
|
case Protocol::Server::Exception:
|
||||||
got_exception_from_server = true;
|
got_exception_from_server = true;
|
||||||
|
|
||||||
if (use_many_replicas)
|
|
||||||
{
|
|
||||||
// Cancel and drain all the remaining connections.
|
|
||||||
replicas_connections->sendCancel();
|
|
||||||
replicas_connections->drainResidualPackets();
|
|
||||||
}
|
|
||||||
|
|
||||||
packet.exception->rethrow();
|
packet.exception->rethrow();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Protocol::Server::EndOfStream:
|
case Protocol::Server::EndOfStream:
|
||||||
finished = true;
|
finished = true;
|
||||||
|
|
||||||
if (use_many_replicas)
|
|
||||||
{
|
|
||||||
// Cancel and drain all the remaining connections.
|
|
||||||
replicas_connections->sendCancel();
|
|
||||||
replicas_connections->drainResidualPackets();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Block();
|
return Block();
|
||||||
|
|
||||||
case Protocol::Server::Progress:
|
case Protocol::Server::Progress:
|
||||||
|
@ -78,6 +78,7 @@ namespace DB
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
ConnectionInfo & info = pickConnection();
|
ConnectionInfo & info = pickConnection();
|
||||||
|
bool retry = false;
|
||||||
|
|
||||||
while (info.is_valid)
|
while (info.is_valid)
|
||||||
{
|
{
|
||||||
@ -92,20 +93,38 @@ namespace DB
|
|||||||
case Protocol::Server::Extremes:
|
case Protocol::Server::Extremes:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case Protocol::Server::EndOfStream:
|
||||||
|
case Protocol::Server::Exception:
|
||||||
info.is_valid = false;
|
info.is_valid = false;
|
||||||
--valid_connections_count;
|
--valid_connections_count;
|
||||||
|
/// Больше ничего не читаем. Закрываем все оставшиеся валидные соединения,
|
||||||
|
/// затем получаем оставшиеся пакеты, чтобы не было рассинхронизации с
|
||||||
|
/// репликами.
|
||||||
|
sendCancel();
|
||||||
|
drainResidualPackets();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/// Мы получили инвалидный пакет от реплики. Повторим попытку
|
||||||
|
/// c другой реплики, если такая найдется.
|
||||||
|
info.is_valid = false;
|
||||||
|
--valid_connections_count;
|
||||||
|
if (valid_connections_count > 0)
|
||||||
|
retry = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.packet_number == next_packet_number)
|
if ((info.packet_number == next_packet_number) && !retry)
|
||||||
{
|
{
|
||||||
++info.packet_number;
|
++info.packet_number;
|
||||||
++next_packet_number;
|
++next_packet_number;
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
++info.packet_number;
|
++info.packet_number;
|
||||||
|
retry = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user