@@ -9,7 +9,7 @@ use crate::{
99 state:: State ,
1010} ;
1111
12- use tracing:: debug;
12+ use tracing:: { debug, error } ;
1313
1414use super :: * ;
1515
@@ -264,7 +264,7 @@ impl QueryEngine {
264264
265265 // Release the connection back into the pool before flushing data to client.
266266 // Flushing can take a minute and we don't want to block the connection from being reused.
267- if self . backend . transaction_mode ( ) && context. requests_left == 0 {
267+ if ! self . backend . session_mode ( ) && context. requests_left == 0 {
268268 self . backend . disconnect ( ) ;
269269 }
270270
@@ -312,18 +312,14 @@ impl QueryEngine {
312312 && !context. admin
313313 && context. client_request . executable ( )
314314 {
315- let bytes_sent = context
316- . stream
317- . error (
318- ErrorResponse :: cross_shard_disabled ( ) ,
319- context. in_transaction ( ) ,
320- )
321- . await ?;
322- self . stats . sent ( bytes_sent) ;
315+ let error = ErrorResponse :: cross_shard_disabled ( ) ;
316+
317+ self . error_response ( context, error) . await ?;
323318
324319 if self . backend . connected ( ) && self . backend . done ( ) {
325320 self . backend . disconnect ( ) ;
326321 }
322+
327323 Ok ( false )
328324 } else {
329325 Ok ( true )
@@ -367,19 +363,31 @@ impl QueryEngine {
367363 {
368364 let error = ErrorResponse :: in_failed_transaction ( ) ;
369365
370- self . hooks . on_engine_error ( context, & error) ?;
371-
372- let bytes_sent = context
373- . stream
374- . error ( error, context. in_transaction ( ) )
375- . await ?;
376- self . stats . sent ( bytes_sent) ;
366+ self . error_response ( context, error) . await ?;
377367
378368 Ok ( false )
379369 } else {
380370 Ok ( true )
381371 }
382372 }
373+
374+ pub ( super ) async fn error_response (
375+ & mut self ,
376+ context : & mut QueryEngineContext < ' _ > ,
377+ error : ErrorResponse ,
378+ ) -> Result < ( ) , Error > {
379+ error ! ( "{:?} [{:?}]" , error. message, context. stream. peer_addr( ) ) ;
380+
381+ self . hooks . on_engine_error ( context, & error) ?;
382+
383+ let bytes_sent = context
384+ . stream
385+ . error ( error, context. in_transaction ( ) )
386+ . await ?;
387+ self . stats . sent ( bytes_sent) ;
388+
389+ return Ok ( ( ) ) ;
390+ }
383391}
384392
385393#[ derive( Debug , Default , Clone ) ]
0 commit comments