Proper placing for DistributedConnectionFailTry

+ better logs
This commit is contained in:
Igor Nikonov 2024-07-09 19:31:33 +00:00
parent 1e72335030
commit beca3b9834
4 changed files with 8 additions and 5 deletions

View File

@ -8,6 +8,7 @@ namespace ProfileEvents
extern const Event DistributedConnectionUsable;
extern const Event DistributedConnectionMissingTable;
extern const Event DistributedConnectionStaleReplica;
extern const Event DistributedConnectionFailTry;
}
namespace DB
@ -97,6 +98,8 @@ void ConnectionEstablisher::run(ConnectionEstablisher::TryResult & result, std::
}
catch (const Exception & e)
{
ProfileEvents::increment(ProfileEvents::DistributedConnectionFailTry);
if (e.code() != ErrorCodes::NETWORK_ERROR && e.code() != ErrorCodes::SOCKET_TIMEOUT
&& e.code() != ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF && e.code() != ErrorCodes::DNS_ERROR)
throw;

View File

@ -7,7 +7,6 @@
namespace ProfileEvents
{
extern const Event HedgedRequestsChangeReplica;
extern const Event DistributedConnectionFailTry;
extern const Event DistributedConnectionFailAtAll;
}
@ -327,7 +326,6 @@ HedgedConnectionsFactory::State HedgedConnectionsFactory::processFinishedConnect
{
ShuffledPool & shuffled_pool = shuffled_pools[index];
LOG_INFO(log, "Connection failed at try №{}, reason: {}", (shuffled_pool.error_count + 1), fail_message);
ProfileEvents::increment(ProfileEvents::DistributedConnectionFailTry);
shuffled_pool.error_count = std::min(pool->getMaxErrorCup(), shuffled_pool.error_count + 1);
shuffled_pool.slowdown_count = 0;

View File

@ -28,7 +28,6 @@ namespace ErrorCodes
namespace ProfileEvents
{
extern const Event DistributedConnectionFailTry;
extern const Event DistributedConnectionFailAtAll;
extern const Event DistributedConnectionSkipReadOnlyReplica;
}
@ -285,7 +284,6 @@ PoolWithFailoverBase<TNestedPool>::getMany(
else
{
LOG_WARNING(log, "Connection failed at try №{}, reason: {}", (shuffled_pool.error_count + 1), fail_message);
ProfileEvents::increment(ProfileEvents::DistributedConnectionFailTry);
shuffled_pool.error_count = std::min(max_error_cap, shuffled_pool.error_count + 1);

View File

@ -106,7 +106,11 @@ RemoteQueryExecutor::RemoteQueryExecutor(
}
else
{
LOG_DEBUG(log, "Failed to connect to replica {}. {}", pool->getAddress(), fail_message);
chassert(!fail_message.empty());
if (result.entry.isNull())
LOG_DEBUG(log, "Failed to connect to replica {}. {}", pool->getAddress(), fail_message);
else
LOG_DEBUG(log, "Replica is not usable for remote query execution: {}. {}", pool->getAddress(), fail_message);
}
auto res = std::make_unique<MultiplexedConnections>(std::move(connection_entries), context, throttler);