Prevent hedged connections overlaps

Some replicas may be in the establishing state, this means that hedged
connection is waiting for TablesStatusResponse, and if the connection
will not be canceled, then next user of the connection will get
TablesStatusResponse, while this is not the expected package, and you
will see:

    DB::Exception: Received from localhost:9000. DB::Exception: Received from ch-1:9000. DB::Exception: Unknown packet 9 from server ch-2:9000: While executing Remote. Stack trace:

Fix this by disconnecting connection to such replicas, note that this
should be fine in general, since they are "slow" anyway (you may wish
configure hedged requests settings to increase timeouts and similar).
This commit is contained in:
Azat Khuzhin 2021-03-20 18:40:00 +03:00
parent 95c87d4ded
commit 17eaddc3ab

View File

@ -38,6 +38,16 @@ HedgedConnectionsFactory::HedgedConnectionsFactory(
HedgedConnectionsFactory::~HedgedConnectionsFactory()
{
/// Stop anything that maybe in progress,
/// to avoid interfer with the subsequent connections.
///
/// I.e. some replcas may be in the establishing state,
/// this means that hedged connection is waiting for TablesStatusResponse,
/// and if the connection will not be canceled,
/// then next user of the connection will get TablesStatusResponse,
/// while this is not the expected package.
stopChoosingReplicas();
pool->updateSharedError(shuffled_pools);
}