Fix async insert logs with setting on mergetree

This commit is contained in:
Raúl Marín 2023-06-20 09:52:11 +02:00
parent 5ee813b8d0
commit 9b899b9351
2 changed files with 15 additions and 6 deletions

View File

@ -317,7 +317,7 @@ QueryLogElement logQueryStart(
elem.query_views = info.views; elem.query_views = info.views;
} }
if (settings.async_insert || async_insert) if (async_insert)
InterpreterInsertQuery::extendQueryLogElemImpl(elem, context); InterpreterInsertQuery::extendQueryLogElemImpl(elem, context);
else if (interpreter) else if (interpreter)
interpreter->extendQueryLogElem(elem, query_ast, context, query_database, query_table); interpreter->extendQueryLogElem(elem, query_ast, context, query_database, query_table);
@ -538,7 +538,7 @@ void logExceptionBeforeStart(
ASTPtr ast, ASTPtr ast,
const std::shared_ptr<OpenTelemetry::SpanHolder> & query_span, const std::shared_ptr<OpenTelemetry::SpanHolder> & query_span,
UInt64 elapsed_millliseconds, UInt64 elapsed_millliseconds,
bool async_insert) bool async_insert_flush)
{ {
auto query_end_time = std::chrono::system_clock::now(); auto query_end_time = std::chrono::system_clock::now();
@ -572,7 +572,7 @@ void logExceptionBeforeStart(
elem.formatted_query = queryToString(ast); elem.formatted_query = queryToString(ast);
} }
if (async_insert) if (async_insert_flush)
elem.query_kind = IAST::QueryKind::AsyncInsertFlush; elem.query_kind = IAST::QueryKind::AsyncInsertFlush;
// We don't calculate databases, tables and columns when the query isn't able to start // We don't calculate databases, tables and columns when the query isn't able to start
@ -1139,7 +1139,16 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
/// Everything related to query log. /// Everything related to query log.
{ {
QueryLogElement elem = logQueryStart( QueryLogElement elem = logQueryStart(
query_start_time, context, query_for_logging, ast, pipeline, interpreter, internal, query_database, query_table); query_start_time,
context,
query_for_logging,
ast,
pipeline,
interpreter,
internal,
query_database,
query_table,
async_insert);
/// Also make possible for caller to log successful query finish and exception during execution. /// Also make possible for caller to log successful query finish and exception during execution.
auto finish_callback = [elem, auto finish_callback = [elem,
context, context,

View File

@ -83,7 +83,7 @@ QueryLogElement logQueryStart(
bool internal, bool internal,
const String & query_database, const String & query_database,
const String & query_table, const String & query_table,
bool async_insert = false); bool async_insert);
void logQueryFinish( void logQueryFinish(
QueryLogElement & elem, QueryLogElement & elem,
@ -109,5 +109,5 @@ void logExceptionBeforeStart(
ASTPtr ast, ASTPtr ast,
const std::shared_ptr<OpenTelemetry::SpanHolder> & query_span, const std::shared_ptr<OpenTelemetry::SpanHolder> & query_span,
UInt64 elapsed_millliseconds, UInt64 elapsed_millliseconds,
bool async_insert = false); bool async_insert_flush = false);
} }