From 3efd9412331910341a6ebd765d1c75e7b6ab0992 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 4 Oct 2022 22:49:43 +0200 Subject: [PATCH] Fix final progress for INSERT SELECT over TCP Move sending of progress and profile events after calling BlockIO::onFinish() since it will call on_finish callback, that will do the final flush of progress (at least WriteProgress). Signed-off-by: Azat Khuzhin --- src/Server/TCPHandler.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index 550ae1bff31..ac179472425 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -369,10 +369,12 @@ void TCPHandler::runImpl() { state.need_receive_data_for_insert = true; processInsertQuery(); + state.io.onFinish(); } else if (state.io.pipeline.pulling()) { processOrdinaryQueryWithProcessors(); + state.io.onFinish(); } else if (state.io.pipeline.completed()) { @@ -398,7 +400,8 @@ void TCPHandler::runImpl() } executor.execute(); - /// Send final progress + state.io.onFinish(); + /// Send final progress after calling onFinish(), since it will update the progress. /// /// NOTE: we cannot send Progress for regular INSERT (with VALUES) /// without breaking protocol compatibility, but it can be done @@ -406,8 +409,10 @@ void TCPHandler::runImpl() sendProgress(); sendSelectProfileEvents(); } - - state.io.onFinish(); + else + { + state.io.onFinish(); + } /// Do it before sending end of stream, to have a chance to show log message in client. query_scope->logPeakMemoryUsage();