diff --git a/src/Client/ClientBase.cpp b/src/Client/ClientBase.cpp
index f0cfd98d045..8eb5381763d 100644
--- a/src/Client/ClientBase.cpp
+++ b/src/Client/ClientBase.cpp
@@ -1474,8 +1474,6 @@ void ClientBase::resetOutput()
out_file_buf->finalize();
out_file_buf.reset();
- if (out_logs_buf)
- out_logs_buf->finalize();
out_logs_buf.reset();
if (pager_cmd)
diff --git a/src/Coordination/KeeperCommon.h b/src/Coordination/KeeperCommon.h
index 02f71a04d06..97774c4d21b 100644
--- a/src/Coordination/KeeperCommon.h
+++ b/src/Coordination/KeeperCommon.h
@@ -1,7 +1,7 @@
#pragma once
#include
-#include "Common/Logger.h"
+#include
namespace DB
{
diff --git a/src/Processors/Transforms/DeduplicationTokenTransforms.h b/src/Processors/Transforms/DeduplicationTokenTransforms.h
index d6aff9e1370..7e5a6101734 100644
--- a/src/Processors/Transforms/DeduplicationTokenTransforms.h
+++ b/src/Processors/Transforms/DeduplicationTokenTransforms.h
@@ -4,7 +4,7 @@
#include
#include
-#include "Common/Logger.h"
+#include
namespace DB
diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp
index 8f836d41b4f..f23adae3e88 100644
--- a/src/Server/TCPHandler.cpp
+++ b/src/Server/TCPHandler.cpp
@@ -686,15 +686,17 @@ void TCPHandler::runImpl()
if (state.empty() || state.cancellation_status == CancellationStatus::FULLY_CANCELLED)
{
state.cancelOut();
- state.reset();
- break;
}
+ else
+ {
+ state.finalizeOut();
+ }
+
/// QueryState should be cleared before QueryScope, since otherwise
/// the MemoryTracker will be wrong for possible deallocations.
/// (i.e. deallocations from the Aggregator with two-level aggregation)
/// Also it resets socket's timeouts.
- state.finalizeOut();
state.reset();
last_sent_snapshots = ProfileEvents::ThreadIdToCountersSnapshot{};
query_scope.reset();