@@ -329,12 +329,11 @@ addPrivilegesInfoToQueryLogElement(QueryLogElement & element, const ContextPtr c
329329}
330330
331331static void
332- addStatusInfoToQueryLogElement (QueryLogElement & element, const QueryStatusInfo & info, const ASTPtr query_ast, const ContextPtr context_ptr)
332+ addStatusInfoToQueryLogElement (QueryLogElement & element, const QueryStatusInfo & info, const ASTPtr query_ast, const ContextPtr context_ptr, std::chrono::system_clock::time_point time )
333333{
334- const auto time_now = std::chrono::system_clock::now ();
335334 UInt64 elapsed_microseconds = info.elapsed_microseconds ;
336- element.event_time = timeInSeconds (time_now );
337- element.event_time_microseconds = timeInMicroseconds (time_now );
335+ element.event_time = timeInSeconds (time );
336+ element.event_time_microseconds = timeInMicroseconds (time );
338337 element.query_duration_ms = elapsed_microseconds / 1000 ;
339338
340339 ProfileEvents::increment (ProfileEvents::QueryTimeMicroseconds, elapsed_microseconds);
@@ -594,7 +593,7 @@ void logQueryFinish(
594593 logQueryMetricLogFinish (context, internal, elem.client_info .current_query_id , time_now, std::make_shared<QueryStatusInfo>(info));
595594 elem.type = QueryLogElementType::QUERY_FINISH;
596595
597- addStatusInfoToQueryLogElement (elem, info, query_ast, context);
596+ addStatusInfoToQueryLogElement (elem, info, query_ast, context, time_now );
598597
599598 auto result_progress = flushQueryProgress (query_pipeline, pulling_pipeline, context->getProgressCallback (), process_list_elem);
600599 elem.result_rows = result_progress.result_rows ;
@@ -687,7 +686,7 @@ void logQueryException(
687686 if (process_list_elem)
688687 {
689688 info = std::make_shared<QueryStatusInfo>(process_list_elem->getInfo (true , settings[Setting::log_profile_events], false ));
690- addStatusInfoToQueryLogElement (elem, *info, query_ast, context);
689+ addStatusInfoToQueryLogElement (elem, *info, query_ast, context, time_now );
691690 }
692691 else
693692 {
0 commit comments