@@ -34,7 +34,7 @@ use crate::observability::driver_tracing::RequestSpan;
3434use crate :: observability:: history:: { self , HistoryListener } ;
3535#[ cfg( feature = "metrics" ) ]
3636use crate :: observability:: metrics:: Metrics ;
37- use crate :: policies:: load_balancing:: { self , RoutingInfo } ;
37+ use crate :: policies:: load_balancing:: { self , LoadBalancingPolicy , RoutingInfo } ;
3838use crate :: policies:: retry:: { RequestInfo , RetryDecision , RetrySession } ;
3939use crate :: response:: query_result:: ColumnSpecs ;
4040use crate :: response:: { NonErrorQueryResponse , QueryResponse } ;
@@ -136,11 +136,11 @@ struct PagerWorker<'a, QueryFunc, SpanCreatorFunc> {
136136 // AsyncFn(Arc<Connection>, Option<Arc<[u8]>>) -> Result<QueryResponse, RequestAttemptError>
137137 page_query : QueryFunc ,
138138
139+ load_balancing_policy : Arc < dyn LoadBalancingPolicy > ,
139140 statement_info : RoutingInfo < ' a > ,
140141 query_is_idempotent : bool ,
141142 query_consistency : Consistency ,
142143 retry_session : Box < dyn RetrySession > ,
143- execution_profile : Arc < ExecutionProfileInner > ,
144144 #[ cfg( feature = "metrics" ) ]
145145 metrics : Arc < Metrics > ,
146146
@@ -162,7 +162,7 @@ where
162162{
163163 // Contract: this function MUST send at least one item through self.sender
164164 async fn work ( mut self , cluster_state : Arc < ClusterState > ) -> PageSendAttemptedProof {
165- let load_balancer = self . execution_profile . load_balancing_policy . clone ( ) ;
165+ let load_balancer = Arc :: clone ( & self . load_balancing_policy ) ;
166166 let statement_info = self . statement_info . clone ( ) ;
167167 let query_plan =
168168 load_balancing:: Plan :: new ( load_balancer. as_ref ( ) , & statement_info, & cluster_state) ;
@@ -335,8 +335,7 @@ where
335335 let _ = self . metrics . log_query_latency ( elapsed. as_millis ( ) as u64 ) ;
336336 self . log_attempt_success ( ) ;
337337 self . log_request_success ( ) ;
338- self . execution_profile
339- . load_balancing_policy
338+ self . load_balancing_policy
340339 . on_request_success ( & self . statement_info , elapsed, node) ;
341340
342341 request_span. record_raw_rows_fields ( & rows) ;
@@ -369,9 +368,12 @@ where
369368 Err ( err) => {
370369 #[ cfg( feature = "metrics" ) ]
371370 self . metrics . inc_failed_paged_queries ( ) ;
372- self . execution_profile
373- . load_balancing_policy
374- . on_request_failure ( & self . statement_info , elapsed, node, & err) ;
371+ self . load_balancing_policy . on_request_failure (
372+ & self . statement_info ,
373+ elapsed,
374+ node,
375+ & err,
376+ ) ;
375377 Err ( err)
376378 }
377379 Ok ( NonErrorQueryResponse {
@@ -391,9 +393,12 @@ where
391393 self . metrics . inc_failed_paged_queries ( ) ;
392394 let err =
393395 RequestAttemptError :: UnexpectedResponse ( response. response . to_response_kind ( ) ) ;
394- self . execution_profile
395- . load_balancing_policy
396- . on_request_failure ( & self . statement_info , elapsed, node, & err) ;
396+ self . load_balancing_policy . on_request_failure (
397+ & self . statement_info ,
398+ elapsed,
399+ node,
400+ & err,
401+ ) ;
397402 Err ( err)
398403 }
399404 }
@@ -693,6 +698,12 @@ impl QueryPager {
693698 ..Default :: default ( )
694699 } ;
695700
701+ let load_balancing_policy = Arc :: clone (
702+ statement
703+ . get_load_balancing_policy ( )
704+ . unwrap_or ( & execution_profile. load_balancing_policy ) ,
705+ ) ;
706+
696707 let retry_session = statement
697708 . get_retry_policy ( )
698709 . map ( |rp| & * * rp)
@@ -733,8 +744,8 @@ impl QueryPager {
733744 statement_info : routing_info,
734745 query_is_idempotent : statement. config . is_idempotent ,
735746 query_consistency : consistency,
747+ load_balancing_policy,
736748 retry_session,
737- execution_profile,
738749 #[ cfg( feature = "metrics" ) ]
739750 metrics,
740751 paging_state : PagingState :: start ( ) ,
@@ -769,6 +780,13 @@ impl QueryPager {
769780
770781 let page_size = config. prepared . get_validated_page_size ( ) ;
771782
783+ let load_balancing_policy = Arc :: clone (
784+ config
785+ . prepared
786+ . get_load_balancing_policy ( )
787+ . unwrap_or ( & config. execution_profile . load_balancing_policy ) ,
788+ ) ;
789+
772790 let retry_session = config
773791 . prepared
774792 . get_retry_policy ( )
@@ -854,8 +872,8 @@ impl QueryPager {
854872 statement_info,
855873 query_is_idempotent : config. prepared . config . is_idempotent ,
856874 query_consistency : consistency,
875+ load_balancing_policy,
857876 retry_session,
858- execution_profile : config. execution_profile ,
859877 #[ cfg( feature = "metrics" ) ]
860878 metrics : config. metrics ,
861879 paging_state : PagingState :: start ( ) ,
0 commit comments