diff --git a/src/Interpreters/InterpreterSystemQuery.cpp b/src/Interpreters/InterpreterSystemQuery.cpp index d9310169ac7..43bb15b70bb 100644 --- a/src/Interpreters/InterpreterSystemQuery.cpp +++ b/src/Interpreters/InterpreterSystemQuery.cpp @@ -573,7 +573,9 @@ StoragePtr InterpreterSystemQuery::tryRestartReplica(const StorageID & replica, database->detachTable(system_context, replica.table_name); } + UUID uuid = table->getStorageID().uuid; table.reset(); + database->waitDetachedTableNotInUse(uuid); /// Attach actions /// getCreateTableQuery must return canonical CREATE query representation, there are no need for AST postprocessing diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index b268179ae93..1fc88168b35 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -428,8 +428,6 @@ void TCPHandler::runImpl() if (e.code() == ErrorCodes::UNKNOWN_PACKET_FROM_CLIENT) throw; - LOG_TEST(log, "Going to close connection due to exception: {}", e.message()); - /// If there is UNEXPECTED_PACKET_FROM_CLIENT emulate network_error /// to break the loop, but do not throw to send the exception to /// the client. @@ -439,6 +437,9 @@ void TCPHandler::runImpl() /// If a timeout occurred, try to inform client about it and close the session if (e.code() == ErrorCodes::SOCKET_TIMEOUT) network_error = true; + + if (network_error) + LOG_TEST(log, "Going to close connection due to exception: {}", e.message()); } catch (const Poco::Net::NetException & e) {