File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,8 @@ impl Database for MySqlDriver<'_> {
81
81
if let Some ( pid) = self . querying_pid . take ( ) {
82
82
let result = sqlx:: raw_sql ( & format ! ( "KILL {pid}" ) ) . execute ( & * self . pool . clone ( ) . unwrap ( ) ) . await ;
83
83
let msg = match result {
84
- Ok ( _) => "successfully killed" . to_string ( ) ,
85
- Err ( e) => format ! ( "failed to kill: {e:?}" ) ,
84
+ Ok ( _) => "Successfully killed" . to_string ( ) ,
85
+ Err ( e) => format ! ( "Failed to kill: {e:?}" ) ,
86
86
} ;
87
87
log:: info!( "Tried to cancel backend process with PID {pid}: {msg} " ) ;
88
88
}
Original file line number Diff line number Diff line change @@ -83,14 +83,23 @@ impl Database for PostgresDriver<'_> {
83
83
_ => { } ,
84
84
} ;
85
85
if let Some ( pid) = self . querying_pid . take ( ) {
86
- let success = sqlx:: raw_sql ( & format ! ( "SELECT pg_cancel_backend({pid})" ) )
87
- . fetch_one ( & * self . pool . clone ( ) . unwrap ( ) )
88
- . await ?
89
- . get :: < bool , _ > ( 0 ) ;
86
+ let result =
87
+ sqlx:: raw_sql ( & format ! ( "SELECT pg_cancel_backend({pid})" ) ) . fetch_one ( & * self . pool . clone ( ) . unwrap ( ) ) . await ;
88
+ let msg = match & result {
89
+ Ok ( _) => "Successfully killed" . to_string ( ) ,
90
+ Err ( e) => format ! ( "Failed to kill: {e:?}" ) ,
91
+ } ;
92
+
93
+ let success = result. as_ref ( ) . is_ok_and ( |r| r. try_get :: < bool , _ > ( 0 ) . unwrap_or ( false ) ) ;
94
+ let status_string =
95
+ result. map_or ( "ERROR" . to_string ( ) , |r| r. try_get_unchecked :: < String , _ > ( 0 ) . unwrap_or ( "ERROR" . to_string ( ) ) ) ;
96
+
90
97
if !success {
91
- log:: warn!( "Failed to cancel backend process with PID {pid}" ) ;
98
+ log:: warn!( "Unexpected response when cancelling backend process with PID {pid}: {msg}" ) ;
99
+ log:: warn!( "Status: {status_string}" ) ;
92
100
} else {
93
- log:: info!( "Cancelled backend process with PID {pid}" ) ;
101
+ log:: info!( "Tried to cancel backend process with PID {pid}: {msg}" ) ;
102
+ log:: info!( "Status: {status_string}" ) ;
94
103
}
95
104
}
96
105
self . querying_conn = None ;
You can’t perform that action at this time.
0 commit comments