@@ -858,6 +858,14 @@ where
858
858
// The query router determines where the query is going to go,
859
859
// e.g. primary, replica, which shard.
860
860
let mut query_router = QueryRouter :: new ( ) ;
861
+ let pool_settings = if self . admin {
862
+ // Admin clients do not use pools.
863
+ ConnectionPool :: default ( ) . settings
864
+ } else {
865
+ self . get_pool ( ) . await ?. settings
866
+ } ;
867
+ query_router. update_pool_settings ( & pool_settings) ;
868
+ query_router. set_default_role ( ) ;
861
869
862
870
self . stats . register ( self . stats . clone ( ) ) ;
863
871
@@ -870,19 +878,6 @@ where
870
878
& self . pool_name ,
871
879
) ;
872
880
873
- // Get a pool instance referenced by the most up-to-date
874
- // pointer. This ensures we always read the latest config
875
- // when starting a query.
876
- let mut pool = if self . admin {
877
- // Admin clients do not use pools.
878
- ConnectionPool :: default ( )
879
- } else {
880
- self . get_pool ( ) . await ?
881
- } ;
882
-
883
- query_router. update_pool_settings ( & pool. settings ) ;
884
- query_router. set_default_role ( ) ;
885
-
886
881
// Our custom protocol loop.
887
882
// We expect the client to either start a transaction with regular queries
888
883
// or issue commands for our sharding and server selection protocol.
@@ -933,6 +928,18 @@ where
933
928
continue ;
934
929
}
935
930
931
+ // Get a pool instance referenced by the most up-to-date
932
+ // pointer. This ensures we always read the latest config
933
+ // when starting a query.
934
+ let mut pool = if self . admin {
935
+ // Admin clients do not use pools.
936
+ ConnectionPool :: default ( )
937
+ } else {
938
+ self . get_pool ( ) . await ?
939
+ } ;
940
+
941
+ query_router. update_pool_settings ( & pool. settings ) ;
942
+
936
943
// Handle all custom protocol commands, if any.
937
944
if self
938
945
. handle_custom_protocol ( & mut query_router, & message, & pool)
@@ -1055,11 +1062,12 @@ where
1055
1062
} ;
1056
1063
1057
1064
// Check if the pool is paused and wait until it's resumed.
1058
- pool. wait_paused ( ) . await ;
1059
-
1060
- // Refresh pool information, something might have changed.
1061
- pool = self . get_pool ( ) . await ?;
1062
- query_router. update_pool_settings ( & pool. settings ) ;
1065
+ if pool. paused ( ) {
1066
+ pool. wait_paused ( ) . await ;
1067
+ // Refresh pool information, something might have changed.
1068
+ pool = self . get_pool ( ) . await ?;
1069
+ query_router. update_pool_settings ( & pool. settings ) ;
1070
+ }
1063
1071
1064
1072
debug ! ( "Waiting for connection from pool" ) ;
1065
1073
if !self . admin {
0 commit comments