File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed
tests/it/servers/admin/v1 Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -53,14 +53,18 @@ pub async fn instance_status_handler() -> poem::Result<impl IntoResponse> {
5353 let ( http_query_count, last_query_finished_at_http) = HttpQueryManager :: instance ( ) . status ( ) ;
5454 let status = session_manager. get_current_session_status ( ) ;
5555
56- let last_query_finished_at = [
57- status. last_query_started_at . map ( unix_timestamp_secs) ,
58- last_query_finished_at_http,
59- ]
60- . iter ( )
61- . flatten ( )
62- . max ( )
63- . copied ( ) ;
56+ let last_query_finished_at = if status. last_query_started_at . is_none ( ) {
57+ None
58+ } else {
59+ [
60+ status. last_query_finished_at . map ( unix_timestamp_secs) ,
61+ last_query_finished_at_http,
62+ ]
63+ . iter ( )
64+ . flatten ( )
65+ . max ( )
66+ . copied ( )
67+ } ;
6468
6569 let status = InstanceStatus {
6670 running_queries_count : status. running_queries_count . max ( http_query_count) ,
Original file line number Diff line number Diff line change @@ -101,11 +101,13 @@ impl Queries {
101101 reason : StopReason ,
102102 now : u64 ,
103103 ) -> ( Option < Arc < HttpQuery > > , bool ) {
104- self . num_active_queries = self . num_active_queries . saturating_sub ( 1 ) ;
105- self . last_query_end_at = Some ( now) ;
106104 let q = self . queries . get ( query_id) . cloned ( ) ;
107105 if let Some ( q) = q {
108106 let stop_first_run = q. mark_stopped ( reason) ;
107+ if stop_first_run {
108+ self . last_query_end_at = Some ( now) ;
109+ self . num_active_queries = self . num_active_queries . saturating_sub ( 1 ) ;
110+ }
109111 return ( Some ( q) , stop_first_run) ;
110112 }
111113 ( None , false )
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ async fn test_status() -> Result<()> {
102102 status. last_query_started_at. is_some( ) ,
103103 status. last_query_finished_at. is_some( ) ,
104104 ) ,
105- ( 1 , true , true ) ,
105+ ( 1 , true , false ) ,
106106 "running"
107107 ) ;
108108
You can’t perform that action at this time.
0 commit comments