Reset replica state in MultiplexedConnections in case of exception.

This commit is contained in:
Nikolai Kochetov 2021-04-19 17:25:43 +03:00
parent 0c23d44b99
commit 0420b7bb33
2 changed files with 13 additions and 2 deletions

View File

@ -278,7 +278,18 @@ Packet MultiplexedConnections::receivePacketUnlocked(AsyncCallback async_callbac
Packet packet;
{
AsyncCallbackSetter async_setter(current_connection, std::move(async_callback));
packet = current_connection->receivePacket();
try
{
packet = current_connection->receivePacket();
}
catch (...)
{
/// Exception may happen when packet is received, e.g. when got unknown packet.
/// In this case, invalidate replica, so that we would not read from it anymore.
current_connection->disconnect();
invalidateReplica(state);
}
}
switch (packet.type)

View File

@ -6,4 +6,4 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
for _ in {1..10}; do $CLICKHOUSE_CLIENT -q "select number from remote('127.0.0.{2,3}', numbers(20)) limit 8 settings max_block_size = 2, unknown_packet_in_send_data=4, sleep_in_send_data_ms=100, async_socket_for_remote=1 format Null" 2>&1 > /dev/null; done
for _ in {1..10}; do $CLICKHOUSE_CLIENT -q "select number from remote('127.0.0.{2,3}', numbers(20)) limit 8 settings max_block_size = 2, unknown_packet_in_send_data=4, sleep_in_send_data_ms=100, async_socket_for_remote=1 format Null" > /dev/null 2>&1 || true; done