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 <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2022-10-04 22:49:43 +02:00
parent 7c1a3996e8
commit 3efd941233

View File

@ -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();