Add LOG_DEBUG for tests debug

This commit is contained in:
Pavel Kruglov 2021-01-29 23:21:11 +03:00
parent 25e85d71ee
commit d27f5114c5
3 changed files with 48 additions and 48 deletions

View File

@ -92,7 +92,7 @@ void Connection::connect(const ConnectionTimeouts & timeouts)
void Connection::disconnect()
{
// LOG_DEBUG(log_wrapper.get(), "disconnect");
LOG_DEBUG(log_wrapper.get(), "disconnect");
maybe_compressed_out = nullptr;
in = nullptr;
@ -106,7 +106,7 @@ void Connection::disconnect()
void Connection::prepare(const ConnectionTimeouts & timeouts)
{
// LOG_DEBUG(log_wrapper.get(), "Connect");
LOG_DEBUG(log_wrapper.get(), "Connect");
LOG_TRACE(log_wrapper.get(), "Connecting. Database: {}. User: {}{}{}",
default_database.empty() ? "(not specified)" : default_database,
@ -160,7 +160,7 @@ void Connection::prepare(const ConnectionTimeouts & timeouts)
void Connection::sendHello()
{
// LOG_DEBUG(log_wrapper.get(), "sendHello");
LOG_DEBUG(log_wrapper.get(), "sendHello");
/** Disallow control characters in user controlled parameters
* to mitigate the possibility of SSRF.
@ -218,7 +218,7 @@ void Connection::sendHello()
void Connection::receiveHello()
{
// LOG_DEBUG(log_wrapper.get(), "receiveHello");
LOG_DEBUG(log_wrapper.get(), "receiveHello");
/// Receive hello packet.
UInt64 packet_type = 0;
@ -323,7 +323,7 @@ const String & Connection::getServerDisplayName(const ConnectionTimeouts & timeo
void Connection::forceConnected(const ConnectionTimeouts & timeouts)
{
// LOG_DEBUG(log_wrapper.get(), "forceConnected");
LOG_DEBUG(log_wrapper.get(), "forceConnected");
if (!connected)
{
@ -351,7 +351,7 @@ void Connection::sendClusterNameAndSalt()
bool Connection::ping()
{
// LOG_DEBUG(log_wrapper.get(), "ping");
LOG_DEBUG(log_wrapper.get(), "ping");
TimeoutSetter timeout_setter(*socket, sync_request_timeout, true);
try
@ -404,7 +404,7 @@ TablesStatusResponse Connection::getTablesStatus(const ConnectionTimeouts & time
void Connection::sendTablesStatusRequest(const TablesStatusRequest & request)
{
// LOG_DEBUG(log_wrapper.get(), "sendTablesStatusRequest");
LOG_DEBUG(log_wrapper.get(), "sendTablesStatusRequest");
writeVarUInt(Protocol::Client::TablesStatusRequest, *out);
request.write(*out, server_revision);
@ -413,7 +413,7 @@ void Connection::sendTablesStatusRequest(const TablesStatusRequest & request)
TablesStatusResponse Connection::receiveTablesStatusResponse()
{
// LOG_DEBUG(log_wrapper.get(), "receiveTablesStatusResponse");
LOG_DEBUG(log_wrapper.get(), "receiveTablesStatusResponse");
UInt64 response_type = 0;
readVarUInt(response_type, *in);
@ -440,7 +440,7 @@ void Connection::sendQuery(
if (!connected)
connect(timeouts);
// LOG_DEBUG(log_wrapper.get(), "sendQuery");
LOG_DEBUG(log_wrapper.get(), "sendQuery");
TimeoutSetter timeout_setter(*socket, timeouts.send_timeout, timeouts.receive_timeout, true);
@ -540,7 +540,7 @@ void Connection::sendCancel()
if (!out)
return;
// LOG_DEBUG(log_wrapper.get(), "sendCancel");
LOG_DEBUG(log_wrapper.get(), "sendCancel");
writeVarUInt(Protocol::Client::Cancel, *out);
out->next();
@ -549,7 +549,7 @@ void Connection::sendCancel()
void Connection::sendData(const Block & block, const String & name, bool scalar)
{
// LOG_DEBUG(log_wrapper.get(), "sendData");
LOG_DEBUG(log_wrapper.get(), "sendData");
if (!block_out)
{
@ -581,7 +581,7 @@ void Connection::sendData(const Block & block, const String & name, bool scalar)
void Connection::sendPreparedData(ReadBuffer & input, size_t size, const String & name)
{
/// NOTE 'Throttler' is not used in this method (could use, but it's not important right now).
// LOG_DEBUG(log_wrapper.get(), "sendPreparedData");
LOG_DEBUG(log_wrapper.get(), "sendPreparedData");
if (input.eof())
throw Exception("Buffer is empty (some kind of corruption)", ErrorCodes::EMPTY_DATA_PASSED);
@ -602,7 +602,7 @@ void Connection::sendScalarsData(Scalars & data)
if (data.empty())
return;
// LOG_DEBUG(log_wrapper.get(), "sendScalarsData");
LOG_DEBUG(log_wrapper.get(), "sendScalarsData");
Stopwatch watch;
size_t out_bytes = out ? out->count() : 0;
@ -689,7 +689,7 @@ void Connection::sendExternalTablesData(ExternalTablesData & data)
return;
}
// LOG_DEBUG(log_wrapper.get(), "sendExternalTablesData");
LOG_DEBUG(log_wrapper.get(), "sendExternalTablesData");
Stopwatch watch;
size_t out_bytes = out ? out->count() : 0;
@ -789,7 +789,7 @@ std::optional<UInt64> Connection::checkPacket(size_t timeout_microseconds)
Packet Connection::receivePacket(AsyncCallback async_callback)
{
// LOG_DEBUG(log_wrapper.get(), "receivePacket");
LOG_DEBUG(log_wrapper.get(), "receivePacket");
in->setAsyncCallback(std::move(async_callback));
SCOPE_EXIT(in->setAsyncCallback({}));

View File

@ -86,7 +86,7 @@ std::vector<GetHedgedConnections::ReplicaStatePtr> GetHedgedConnections::getMany
GetHedgedConnections::ReplicaStatePtr GetHedgedConnections::getNextConnection(bool non_blocking)
{
// LOG_DEBUG(log, "getNextConnection");
LOG_DEBUG(log, "getNextConnection");
ReplicaStatePtr replica = createNewReplica();
int index;
@ -161,7 +161,7 @@ GetHedgedConnections::ReplicaStatePtr GetHedgedConnections::getNextConnection(bo
void GetHedgedConnections::stopChoosingReplicas()
{
// LOG_DEBUG(log, "stopChoosingReplicas");
LOG_DEBUG(log, "stopChoosingReplicas");
for (auto & [fd, replica] : fd_to_replica)
{
removeTimeoutsFromReplica(replica, epoll, timeout_fd_to_replica);
@ -195,7 +195,7 @@ int GetHedgedConnections::getNextIndex()
return -1;
}
// LOG_DEBUG(log, "get next index: {}", next_index);
LOG_DEBUG(log, "get next index: {}", next_index);
last_used_index = next_index;
return next_index;
@ -203,7 +203,7 @@ int GetHedgedConnections::getNextIndex()
GetHedgedConnections::Action GetHedgedConnections::startTryGetConnection(int index, ReplicaStatePtr & replica)
{
// LOG_DEBUG(log, "start try get connection with {} replica", index);
LOG_DEBUG(log, "start try get connection with {} replica", index);
TryGetConnection & try_get_connection = try_get_connections[index];
replica->state = State::NOT_READY;
@ -240,14 +240,14 @@ GetHedgedConnections::Action GetHedgedConnections::startTryGetConnection(int ind
GetHedgedConnections::Action
GetHedgedConnections::processTryGetConnectionStage(ReplicaStatePtr & replica, bool remove_from_epoll)
{
// LOG_DEBUG(log, "process get connection stage for {} replica", replica->index);
LOG_DEBUG(log, "process get connection stage for {} replica", replica->index);
TryGetConnection & try_get_connection = try_get_connections[replica->index];
if (try_get_connection.stage == TryGetConnection::Stage::FINISHED)
{
indexes_in_process.erase(replica->index);
// LOG_DEBUG(log, "stage: FINISHED");
LOG_DEBUG(log, "stage: FINISHED");
++entries_count;
if (remove_from_epoll)
@ -258,11 +258,11 @@ GetHedgedConnections::processTryGetConnectionStage(ReplicaStatePtr & replica, bo
if (try_get_connection.result.is_usable)
{
// LOG_DEBUG(log, "replica is usable");
LOG_DEBUG(log, "replica is usable");
++usable_count;
if (try_get_connection.result.is_up_to_date)
{
// LOG_DEBUG(log, "replica is up to date, finish get hedged connections");
LOG_DEBUG(log, "replica is up to date, finish get hedged connections");
replica->state = State::READY;
ready_indexes.insert(replica->index);
return Action::FINISH;
@ -276,12 +276,12 @@ GetHedgedConnections::processTryGetConnectionStage(ReplicaStatePtr & replica, bo
}
else if (try_get_connection.stage == TryGetConnection::Stage::FAILED)
{
// LOG_DEBUG(log, "stage: FAILED");
LOG_DEBUG(log, "stage: FAILED");
processFailedConnection(replica);
return Action::TRY_NEXT_REPLICA;
}
// LOG_DEBUG(log, "middle stage, process epoll events");
LOG_DEBUG(log, "middle stage, process epoll events");
/// Get connection process is not finished
return Action::PROCESS_EPOLL_EVENTS;
@ -289,7 +289,7 @@ GetHedgedConnections::processTryGetConnectionStage(ReplicaStatePtr & replica, bo
void GetHedgedConnections::processFailedConnection(ReplicaStatePtr & replica)
{
// LOG_DEBUG(log, "failed connection with {} replica", replica->index);
LOG_DEBUG(log, "failed connection with {} replica", replica->index);
ShuffledPool & shuffled_pool = shuffled_pools[replica->index];
LOG_WARNING(
@ -314,7 +314,7 @@ void GetHedgedConnections::processFailedConnection(ReplicaStatePtr & replica)
void GetHedgedConnections::addTimeouts(ReplicaStatePtr & replica)
{
// LOG_DEBUG(log, "add timeouts for {} replica", replica->index);
LOG_DEBUG(log, "add timeouts for {} replica", replica->index);
addTimeoutToReplica(TimerTypes::RECEIVE_TIMEOUT, replica, epoll, timeout_fd_to_replica, timeouts);
@ -327,7 +327,7 @@ void GetHedgedConnections::addTimeouts(ReplicaStatePtr & replica)
GetHedgedConnections::ReplicaStatePtr GetHedgedConnections::processEpollEvents(bool non_blocking)
{
// LOG_DEBUG(log, "process epoll events");
LOG_DEBUG(log, "process epoll events");
int event_fd;
ReplicaStatePtr replica = nullptr;
bool finish = false;
@ -349,7 +349,7 @@ GetHedgedConnections::ReplicaStatePtr GetHedgedConnections::processEpollEvents(b
throw Exception("Unknown event from epoll", ErrorCodes::LOGICAL_ERROR);
}
// LOG_DEBUG(log, "cancel process epoll events");
LOG_DEBUG(log, "cancel process epoll events");
return replica;
}
@ -365,7 +365,7 @@ int GetHedgedConnections::getReadyFileDescriptor(AsyncCallback async_callback)
bool GetHedgedConnections::processReplicaEvent(ReplicaStatePtr & replica, bool non_blocking)
{
// LOG_DEBUG(log, "epoll event is {} replica", replica->index);
LOG_DEBUG(log, "epoll event is {} replica", replica->index);
removeTimeoutsFromReplica(replica, epoll, timeout_fd_to_replica);
try_get_connections[replica->index].run();
Action action = processTryGetConnectionStage(replica, true);
@ -380,7 +380,7 @@ bool GetHedgedConnections::processReplicaEvent(ReplicaStatePtr & replica, bool n
bool GetHedgedConnections::processTimeoutEvent(ReplicaStatePtr & replica, TimerDescriptorPtr timeout_descriptor, bool non_blocking)
{
// LOG_DEBUG(log, "epoll event is timeout for {} replica", replica->index);
LOG_DEBUG(log, "epoll event is timeout for {} replica", replica->index);
epoll.remove(timeout_descriptor->getDescriptor());
replica->active_timeouts.erase(timeout_descriptor->getDescriptor());
@ -388,7 +388,7 @@ bool GetHedgedConnections::processTimeoutEvent(ReplicaStatePtr & replica, TimerD
if (timeout_descriptor->getType() == TimerTypes::RECEIVE_TIMEOUT)
{
// LOG_DEBUG(log, "process receive timeout for {} replica", replica->index);
LOG_DEBUG(log, "process receive timeout for {} replica", replica->index);
removeTimeoutsFromReplica(replica, epoll, timeout_fd_to_replica);
epoll.remove(replica->fd);
fd_to_replica.erase(replica->fd);
@ -415,7 +415,7 @@ bool GetHedgedConnections::processTimeoutEvent(ReplicaStatePtr & replica, TimerD
void GetHedgedConnections::setBestUsableReplica(ReplicaStatePtr & replica)
{
// LOG_DEBUG(log, "set best usable replica");
LOG_DEBUG(log, "set best usable replica");
std::vector<int> indexes(try_get_connections.size());
for (size_t i = 0; i != indexes.size(); ++i)

View File

@ -59,7 +59,7 @@ void HedgedConnections::sendScalarsData(Scalars & data)
{
std::lock_guard lock(cancel_mutex);
// LOG_DEBUG(log, "sendScalarsData");
LOG_DEBUG(log, "sendScalarsData");
if (!sent_query)
throw Exception("Cannot send scalars data: query not yet sent.", ErrorCodes::LOGICAL_ERROR);
@ -78,7 +78,7 @@ void HedgedConnections::sendExternalTablesData(std::vector<ExternalTablesData> &
{
std::lock_guard lock(cancel_mutex);
// LOG_DEBUG(log, "sendExternalTablesData");
LOG_DEBUG(log, "sendExternalTablesData");
if (!sent_query)
throw Exception("Cannot send external tables data: query not yet sent.", ErrorCodes::LOGICAL_ERROR);
@ -106,7 +106,7 @@ void HedgedConnections::sendQuery(
{
std::lock_guard lock(cancel_mutex);
// LOG_DEBUG(log, "sendQuery");
LOG_DEBUG(log, "sendQuery");
if (sent_query)
throw Exception("Query already sent.", ErrorCodes::LOGICAL_ERROR);
@ -159,7 +159,7 @@ void HedgedConnections::disconnect()
{
std::lock_guard lock(cancel_mutex);
// LOG_DEBUG(log, "disconnect");
LOG_DEBUG(log, "disconnect");
for (auto & replicas_with_same_offset : replicas)
for (auto & replica : replicas_with_same_offset)
@ -178,7 +178,7 @@ std::string HedgedConnections::dumpAddresses() const
{
std::lock_guard lock(cancel_mutex);
// LOG_DEBUG(log, "dumpAddresses");
LOG_DEBUG(log, "dumpAddresses");
std::string addresses;
bool is_first = true;
@ -202,7 +202,7 @@ void HedgedConnections::sendCancel()
{
std::lock_guard lock(cancel_mutex);
// LOG_DEBUG(log, "sendCancel");
LOG_DEBUG(log, "sendCancel");
if (!sent_query || cancelled)
throw Exception("Cannot cancel. Either no query sent or already cancelled.", ErrorCodes::LOGICAL_ERROR);
@ -223,7 +223,7 @@ Packet HedgedConnections::drain()
if (!cancelled)
throw Exception("Cannot drain connections: cancel first.", ErrorCodes::LOGICAL_ERROR);
// LOG_DEBUG(log, "drain");
LOG_DEBUG(log, "drain");
Packet res;
res.type = Protocol::Server::EndOfStream;
@ -273,7 +273,7 @@ Packet HedgedConnections::receivePacketUnlocked(AsyncCallback async_callback)
Packet HedgedConnections::receivePacketImpl(AsyncCallback async_callback)
{
// LOG_DEBUG(log, "sreceivePacketImpl");
LOG_DEBUG(log, "sreceivePacketImpl");
int event_fd;
ReplicaStatePtr replica = nullptr;
@ -285,14 +285,14 @@ Packet HedgedConnections::receivePacketImpl(AsyncCallback async_callback)
if (fd_to_replica.find(event_fd) != fd_to_replica.end())
{
// LOG_DEBUG(log, "event is replica");
LOG_DEBUG(log, "event is replica");
replica = fd_to_replica[event_fd];
packet = receivePacketFromReplica(replica, async_callback);
finish = true;
}
else if (timeout_fd_to_replica.find(event_fd) != timeout_fd_to_replica.end())
{
// LOG_DEBUG(log, "event is timeout");
LOG_DEBUG(log, "event is timeout");
replica = timeout_fd_to_replica[event_fd];
processTimeoutEvent(replica, replica->active_timeouts[event_fd].get());
}
@ -316,7 +316,7 @@ int HedgedConnections::getReadyFileDescriptor(AsyncCallback async_callback)
Packet HedgedConnections::receivePacketFromReplica(ReplicaStatePtr & replica, AsyncCallback async_callback)
{
// LOG_DEBUG(log, "sreceivePacketFromReplica");
LOG_DEBUG(log, "sreceivePacketFromReplica");
Packet packet = replica->connection->receivePacket(std::move(async_callback));
switch (packet.type)
{
@ -352,7 +352,7 @@ void HedgedConnections::processReceiveData(ReplicaStatePtr & replica)
/// When we receive first packet of data from any replica, we continue working with this replica
/// and stop working with other replicas (if there are other replicas).
// LOG_DEBUG(log, "processReceiveData");
LOG_DEBUG(log, "processReceiveData");
offsets_with_received_data.insert(replica->parallel_replica_offset);
@ -397,7 +397,7 @@ void HedgedConnections::processTimeoutEvent(ReplicaStatePtr & replica, TimerDesc
void HedgedConnections::tryGetNewReplica()
{
// LOG_DEBUG(log, "tryGetNewReplica");
LOG_DEBUG(log, "tryGetNewReplica");
ReplicaStatePtr new_replica = get_hedged_connections.getNextConnection(/*non_blocking*/ true);
@ -408,7 +408,7 @@ void HedgedConnections::tryGetNewReplica()
if (new_replica->isReady())
{
// LOG_DEBUG(log, "processNewReadyReplica");
LOG_DEBUG(log, "processNewReadyReplica");
new_replica->parallel_replica_offset = offsets_queue.front();
offsets_queue.pop();
replicas[new_replica->parallel_replica_offset].push_back(new_replica);
@ -432,7 +432,7 @@ void HedgedConnections::tryGetNewReplica()
void HedgedConnections::finishProcessReplica(ReplicaStatePtr & replica, bool disconnect)
{
// LOG_DEBUG(log, "finishProcessReplica");
LOG_DEBUG(log, "finishProcessReplica");
removeTimeoutsFromReplica(replica, epoll, timeout_fd_to_replica);
epoll.remove(replica->fd);