@@ -15,7 +15,8 @@ use crate::cluster::node::CloudEndpoint;
15
15
use crate :: cluster:: node:: { InternalKnownNode , KnownNode , NodeRef } ;
16
16
use crate :: cluster:: { Cluster , ClusterNeatDebug , ClusterState } ;
17
17
use crate :: errors:: {
18
- BadQuery , NewSessionError , ProtocolError , QueryError , RequestAttemptError , TracingProtocolError ,
18
+ BadQuery , NewSessionError , ProtocolError , QueryError , RequestAttemptError , RequestError ,
19
+ TracingProtocolError ,
19
20
} ;
20
21
use crate :: frame:: response:: result;
21
22
#[ cfg( feature = "ssl" ) ]
@@ -1849,11 +1850,11 @@ where
1849
1850
QueryFut : Future < Output = Result < ResT , RequestAttemptError > > ,
1850
1851
ResT : AllowedRunRequestResTType ,
1851
1852
{
1852
- let history_listener_and_id: Option < ( & ' a dyn HistoryListener , history:: QueryId ) > =
1853
+ let history_listener_and_id: Option < ( & ' a dyn HistoryListener , history:: RequestId ) > =
1853
1854
statement_config
1854
1855
. history_listener
1855
1856
. as_ref ( )
1856
- . map ( |hl| ( & * * hl, hl. log_query_start ( ) ) ) ;
1857
+ . map ( |hl| ( & * * hl, hl. log_request_start ( ) ) ) ;
1857
1858
1858
1859
let load_balancer = & execution_profile. load_balancing_policy ;
1859
1860
@@ -1899,16 +1900,18 @@ where
1899
1900
let request_runner_generator = |is_speculative : bool | {
1900
1901
let history_data: Option < HistoryData > = history_listener_and_id
1901
1902
. as_ref ( )
1902
- . map ( |( history_listener, query_id ) | {
1903
+ . map ( |( history_listener, request_id ) | {
1903
1904
let speculative_id: Option < history:: SpeculativeId > =
1904
1905
if is_speculative {
1905
- Some ( history_listener. log_new_speculative_fiber ( * query_id) )
1906
+ Some (
1907
+ history_listener. log_new_speculative_fiber ( * request_id) ,
1908
+ )
1906
1909
} else {
1907
1910
None
1908
1911
} ;
1909
1912
HistoryData {
1910
1913
listener : * history_listener,
1911
- query_id : * query_id ,
1914
+ request_id : * request_id ,
1912
1915
speculative_id,
1913
1916
}
1914
1917
} ) ;
@@ -1947,9 +1950,9 @@ where
1947
1950
let history_data: Option < HistoryData > =
1948
1951
history_listener_and_id
1949
1952
. as_ref ( )
1950
- . map ( |( history_listener, query_id ) | HistoryData {
1953
+ . map ( |( history_listener, request_id ) | HistoryData {
1951
1954
listener : * history_listener,
1952
- query_id : * query_id ,
1955
+ request_id : * request_id ,
1953
1956
speculative_id : None ,
1954
1957
} ) ;
1955
1958
self . run_request_speculative_fiber (
@@ -1966,7 +1969,7 @@ where
1966
1969
} ,
1967
1970
)
1968
1971
. await
1969
- . unwrap_or ( Err ( QueryError :: EmptyPlan ) )
1972
+ . unwrap_or ( Err ( RequestError :: EmptyPlan ) )
1970
1973
}
1971
1974
}
1972
1975
} ;
@@ -1977,24 +1980,19 @@ where
1977
1980
let result = match effective_timeout {
1978
1981
Some ( timeout) => tokio:: time:: timeout ( timeout, runner)
1979
1982
. await
1980
- . unwrap_or_else ( |e| {
1981
- Err ( QueryError :: RequestTimeout ( format ! (
1982
- "Request took longer than {}ms: {}" ,
1983
- timeout. as_millis( ) ,
1984
- e
1985
- ) ) )
1986
- } ) ,
1987
- None => runner. await ,
1983
+ . map ( |res| res. map_err ( RequestError :: from) )
1984
+ . unwrap_or_else ( |_| Err ( RequestError :: RequestTimeout ( timeout) ) ) ,
1985
+ None => runner. await . map_err ( RequestError :: from) ,
1988
1986
} ;
1989
1987
1990
- if let Some ( ( history_listener, query_id ) ) = history_listener_and_id {
1988
+ if let Some ( ( history_listener, request_id ) ) = history_listener_and_id {
1991
1989
match & result {
1992
- Ok ( _) => history_listener. log_query_success ( query_id ) ,
1993
- Err ( e) => history_listener. log_query_error ( query_id , e) ,
1990
+ Ok ( _) => history_listener. log_request_success ( request_id ) ,
1991
+ Err ( e) => history_listener. log_request_error ( request_id , e) ,
1994
1992
}
1995
1993
}
1996
1994
1997
- result
1995
+ result. map_err ( RequestError :: into_query_error )
1998
1996
}
1999
1997
2000
1998
/// Executes the closure `run_request_once`, provided the load balancing plan and some information
@@ -2008,12 +2006,12 @@ where
2008
2006
run_request_once : impl Fn ( Arc < Connection > , Consistency , & ExecutionProfileInner ) -> QueryFut ,
2009
2007
execution_profile : & ExecutionProfileInner ,
2010
2008
mut context : ExecuteRequestContext < ' a > ,
2011
- ) -> Option < Result < RunRequestResult < ResT > , QueryError > >
2009
+ ) -> Option < Result < RunRequestResult < ResT > , RequestError > >
2012
2010
where
2013
2011
QueryFut : Future < Output = Result < ResT , RequestAttemptError > > ,
2014
2012
ResT : AllowedRunRequestResTType ,
2015
2013
{
2016
- let mut last_error: Option < QueryError > = None ;
2014
+ let mut last_error: Option < RequestError > = None ;
2017
2015
let mut current_consistency: Consistency = context
2018
2016
. consistency_set_on_statement
2019
2017
. unwrap_or ( execution_profile. consistency ) ;
@@ -2097,12 +2095,9 @@ where
2097
2095
retry_decision = ?retry_decision
2098
2096
) ;
2099
2097
2100
- last_error = Some ( request_error. into_query_error ( ) ) ;
2101
- context. log_attempt_error (
2102
- & attempt_id,
2103
- last_error. as_ref ( ) . unwrap ( ) ,
2104
- & retry_decision,
2105
- ) ;
2098
+ context. log_attempt_error ( & attempt_id, & request_error, & retry_decision) ;
2099
+
2100
+ last_error = Some ( request_error. into ( ) ) ;
2106
2101
2107
2102
match retry_decision {
2108
2103
RetryDecision :: RetrySameNode ( new_cl) => {
@@ -2142,8 +2137,8 @@ where
2142
2137
self . await_schema_agreement_indefinitely ( ) ,
2143
2138
)
2144
2139
. await
2145
- . unwrap_or ( Err ( QueryError :: RequestTimeout (
2146
- "schema agreement not reached in time" . to_owned ( ) ,
2140
+ . unwrap_or ( Err ( QueryError :: SchemaAgreementTimeout (
2141
+ self . schema_agreement_timeout ,
2147
2142
) ) )
2148
2143
}
2149
2144
@@ -2192,15 +2187,15 @@ struct ExecuteRequestContext<'a> {
2192
2187
2193
2188
struct HistoryData < ' a > {
2194
2189
listener : & ' a dyn HistoryListener ,
2195
- query_id : history:: QueryId ,
2190
+ request_id : history:: RequestId ,
2196
2191
speculative_id : Option < history:: SpeculativeId > ,
2197
2192
}
2198
2193
2199
2194
impl ExecuteRequestContext < ' _ > {
2200
2195
fn log_attempt_start ( & self , node_addr : SocketAddr ) -> Option < history:: AttemptId > {
2201
2196
self . history_data . as_ref ( ) . map ( |hd| {
2202
2197
hd. listener
2203
- . log_attempt_start ( hd. query_id , hd. speculative_id , node_addr)
2198
+ . log_attempt_start ( hd. request_id , hd. speculative_id , node_addr)
2204
2199
} )
2205
2200
}
2206
2201
@@ -2221,7 +2216,7 @@ impl ExecuteRequestContext<'_> {
2221
2216
fn log_attempt_error (
2222
2217
& self ,
2223
2218
attempt_id_opt : & Option < history:: AttemptId > ,
2224
- error : & QueryError ,
2219
+ error : & RequestAttemptError ,
2225
2220
retry_decision : & RetryDecision ,
2226
2221
) {
2227
2222
let attempt_id: & history:: AttemptId = match attempt_id_opt {
0 commit comments