diff --git a/scylla/src/client/pager.rs b/scylla/src/client/pager.rs index ee58ba0e8..0874cc411 100644 --- a/scylla/src/client/pager.rs +++ b/scylla/src/client/pager.rs @@ -37,7 +37,7 @@ use crate::observability::driver_tracing::RequestSpan; use crate::observability::history::{self, HistoryListener}; use crate::observability::metrics::Metrics; use crate::policies::load_balancing::{self, RoutingInfo}; -use crate::policies::retry::{QueryInfo, RetryDecision, RetrySession}; +use crate::policies::retry::{RequestInfo, RetryDecision, RetrySession}; use crate::response::query_result::ColumnSpecs; use crate::response::{NonErrorQueryResponse, QueryResponse}; use crate::statement::{prepared_statement::PreparedStatement, query::Query}; @@ -223,7 +223,7 @@ where }; // Use retry policy to decide what to do next - let query_info = QueryInfo { + let query_info = RequestInfo { error: &request_error, is_idempotent: self.query_is_idempotent, consistency: self.query_consistency, diff --git a/scylla/src/client/session.rs b/scylla/src/client/session.rs index 4f97a4e73..2ba11889b 100644 --- a/scylla/src/client/session.rs +++ b/scylla/src/client/session.rs @@ -28,7 +28,7 @@ use crate::observability::tracing::TracingInfo; use crate::policies::address_translator::AddressTranslator; use crate::policies::host_filter::HostFilter; use crate::policies::load_balancing::{self, RoutingInfo}; -use crate::policies::retry::{QueryInfo, RetryDecision, RetrySession}; +use crate::policies::retry::{RequestInfo, RetryDecision, RetrySession}; use crate::policies::speculative_execution; use crate::prepared_statement::PreparedStatement; use crate::query::Query; @@ -2085,7 +2085,7 @@ where }; // Use retry policy to decide what to do next - let query_info = QueryInfo { + let query_info = RequestInfo { error: &request_error, is_idempotent: context.is_idempotent, consistency: context diff --git a/scylla/src/client/session_test.rs b/scylla/src/client/session_test.rs index 677acef49..5f7e6f90c 100644 --- a/scylla/src/client/session_test.rs +++ b/scylla/src/client/session_test.rs @@ -9,7 +9,7 @@ use crate::cluster::metadata::{CollectionType, ColumnKind, CqlType, NativeType, use crate::deserialize::DeserializeOwnedValue; use crate::errors::{BadKeyspaceName, BadQuery, DbError, QueryError}; use crate::observability::tracing::TracingInfo; -use crate::policies::retry::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}; +use crate::policies::retry::{RequestInfo, RetryDecision, RetryPolicy, RetrySession}; use crate::prepared_statement::PreparedStatement; use crate::query::Query; use crate::routing::partitioner::{ @@ -2725,7 +2725,7 @@ async fn test_iter_works_when_retry_policy_returns_ignore_write_error() { struct MyRetrySession(Arc); impl RetrySession for MyRetrySession { - fn decide_should_retry(&mut self, _: QueryInfo) -> RetryDecision { + fn decide_should_retry(&mut self, _: RequestInfo) -> RetryDecision { self.0.store(true, Ordering::Relaxed); RetryDecision::IgnoreWriteError } diff --git a/scylla/src/policies/retry/default.rs b/scylla/src/policies/retry/default.rs index 66de11e6e..dacf13b86 100644 --- a/scylla/src/policies/retry/default.rs +++ b/scylla/src/policies/retry/default.rs @@ -2,7 +2,7 @@ use scylla_cql::frame::response::error::{DbError, WriteType}; use crate::errors::RequestAttemptError; -use super::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}; +use super::{RequestInfo, RetryDecision, RetryPolicy, RetrySession}; /// Default retry policy - retries when there is a high chance that a retry might help.\ /// Behaviour based on [DataStax Java Driver](https://docs.datastax.com/en/developer/java-driver/4.10/manual/core/retries/) @@ -50,18 +50,18 @@ impl Default for DefaultRetrySession { } impl RetrySession for DefaultRetrySession { - fn decide_should_retry(&mut self, query_info: QueryInfo) -> RetryDecision { - if query_info.consistency.is_serial() { + fn decide_should_retry(&mut self, request_info: RequestInfo) -> RetryDecision { + if request_info.consistency.is_serial() { return RetryDecision::DontRetry; }; - match query_info.error { + match request_info.error { // Basic errors - there are some problems on this node // Retry on a different one if possible RequestAttemptError::BrokenConnectionError(_) | RequestAttemptError::DbError(DbError::Overloaded, _) | RequestAttemptError::DbError(DbError::ServerError, _) | RequestAttemptError::DbError(DbError::TruncateError, _) => { - if query_info.is_idempotent { + if request_info.is_idempotent { RetryDecision::RetryNextNode(None) } else { RetryDecision::DontRetry @@ -108,7 +108,7 @@ impl RetrySession for DefaultRetrySession { // By the time we retry they should be detected as dead. RequestAttemptError::DbError(DbError::WriteTimeout { write_type, .. }, _) => { if !self.was_write_timeout_retry - && query_info.is_idempotent + && request_info.is_idempotent && *write_type == WriteType::BatchLog { self.was_write_timeout_retry = true; @@ -117,7 +117,7 @@ impl RetrySession for DefaultRetrySession { RetryDecision::DontRetry } } - // The node is still bootstrapping it can't execute the query, we should try another one + // The node is still bootstrapping it can't execute the request, we should try another one RequestAttemptError::DbError(DbError::IsBootstrapping, _) => { RetryDecision::RetryNextNode(None) } @@ -135,7 +135,7 @@ impl RetrySession for DefaultRetrySession { #[cfg(test)] mod tests { - use super::{DefaultRetryPolicy, QueryInfo, RetryDecision, RetryPolicy}; + use super::{DefaultRetryPolicy, RequestInfo, RetryDecision, RetryPolicy}; use crate::errors::{BrokenConnectionErrorKind, RequestAttemptError}; use crate::errors::{DbError, WriteType}; use crate::statement::Consistency; @@ -143,8 +143,8 @@ mod tests { use bytes::Bytes; use scylla_cql::frame::frame_errors::{BatchSerializationError, CqlRequestSerializationError}; - fn make_query_info(error: &RequestAttemptError, is_idempotent: bool) -> QueryInfo<'_> { - QueryInfo { + fn make_request_info(error: &RequestAttemptError, is_idempotent: bool) -> RequestInfo<'_> { + RequestInfo { error, is_idempotent, consistency: Consistency::One, @@ -155,13 +155,13 @@ mod tests { fn default_policy_assert_never_retries(error: RequestAttemptError) { let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&error, false)), + policy.decide_should_retry(make_request_info(&error, false)), RetryDecision::DontRetry ); let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&error, true)), + policy.decide_should_retry(make_request_info(&error, true)), RetryDecision::DontRetry ); } @@ -229,13 +229,13 @@ mod tests { fn default_policy_assert_idempotent_next(error: RequestAttemptError) { let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&error, false)), + policy.decide_should_retry(make_request_info(&error, false)), RetryDecision::DontRetry ); let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&error, true)), + policy.decide_should_retry(make_request_info(&error, true)), RetryDecision::RetryNextNode(None) ); } @@ -265,13 +265,13 @@ mod tests { let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&error, false)), + policy.decide_should_retry(make_request_info(&error, false)), RetryDecision::RetryNextNode(None) ); let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&error, true)), + policy.decide_should_retry(make_request_info(&error, true)), RetryDecision::RetryNextNode(None) ); } @@ -291,21 +291,21 @@ mod tests { let mut policy_not_idempotent = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy_not_idempotent.decide_should_retry(make_query_info(&error, false)), + policy_not_idempotent.decide_should_retry(make_request_info(&error, false)), RetryDecision::RetryNextNode(None) ); assert_eq!( - policy_not_idempotent.decide_should_retry(make_query_info(&error, false)), + policy_not_idempotent.decide_should_retry(make_request_info(&error, false)), RetryDecision::DontRetry ); let mut policy_idempotent = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy_idempotent.decide_should_retry(make_query_info(&error, true)), + policy_idempotent.decide_should_retry(make_request_info(&error, true)), RetryDecision::RetryNextNode(None) ); assert_eq!( - policy_idempotent.decide_should_retry(make_query_info(&error, true)), + policy_idempotent.decide_should_retry(make_request_info(&error, true)), RetryDecision::DontRetry ); } @@ -328,22 +328,22 @@ mod tests { // Not idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&enough_responses_no_data, false)), + policy.decide_should_retry(make_request_info(&enough_responses_no_data, false)), RetryDecision::RetrySameNode(None) ); assert_eq!( - policy.decide_should_retry(make_query_info(&enough_responses_no_data, false)), + policy.decide_should_retry(make_request_info(&enough_responses_no_data, false)), RetryDecision::DontRetry ); // Idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&enough_responses_no_data, true)), + policy.decide_should_retry(make_request_info(&enough_responses_no_data, true)), RetryDecision::RetrySameNode(None) ); assert_eq!( - policy.decide_should_retry(make_query_info(&enough_responses_no_data, true)), + policy.decide_should_retry(make_request_info(&enough_responses_no_data, true)), RetryDecision::DontRetry ); @@ -362,14 +362,14 @@ mod tests { // Not idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&enough_responses_with_data, false)), + policy.decide_should_retry(make_request_info(&enough_responses_with_data, false)), RetryDecision::DontRetry ); // Idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&enough_responses_with_data, true)), + policy.decide_should_retry(make_request_info(&enough_responses_with_data, true)), RetryDecision::DontRetry ); @@ -387,19 +387,19 @@ mod tests { // Not idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(¬_enough_responses_with_data, false)), + policy.decide_should_retry(make_request_info(¬_enough_responses_with_data, false)), RetryDecision::DontRetry ); // Idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(¬_enough_responses_with_data, true)), + policy.decide_should_retry(make_request_info(¬_enough_responses_with_data, true)), RetryDecision::DontRetry ); } - // WriteTimeout will retry once when the query is idempotent and write_type == BatchLog + // WriteTimeout will retry once when the request is idempotent and write_type == BatchLog #[test] fn default_write_timeout() { setup_tracing(); @@ -417,18 +417,18 @@ mod tests { // Not idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&good_write_type, false)), + policy.decide_should_retry(make_request_info(&good_write_type, false)), RetryDecision::DontRetry ); // Idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&good_write_type, true)), + policy.decide_should_retry(make_request_info(&good_write_type, true)), RetryDecision::RetrySameNode(None) ); assert_eq!( - policy.decide_should_retry(make_query_info(&good_write_type, true)), + policy.decide_should_retry(make_request_info(&good_write_type, true)), RetryDecision::DontRetry ); @@ -446,14 +446,14 @@ mod tests { // Not idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&bad_write_type, false)), + policy.decide_should_retry(make_request_info(&bad_write_type, false)), RetryDecision::DontRetry ); // Idempotent let mut policy = DefaultRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info(&bad_write_type, true)), + policy.decide_should_retry(make_request_info(&bad_write_type, true)), RetryDecision::DontRetry ); } diff --git a/scylla/src/policies/retry/downgrading_consistency.rs b/scylla/src/policies/retry/downgrading_consistency.rs index 291e73fc2..79d0be396 100644 --- a/scylla/src/policies/retry/downgrading_consistency.rs +++ b/scylla/src/policies/retry/downgrading_consistency.rs @@ -1,7 +1,7 @@ use scylla_cql::Consistency; use tracing::debug; -use super::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}; +use super::{RequestInfo, RetryDecision, RetryPolicy, RetrySession}; use crate::errors::{DbError, RequestAttemptError, WriteType}; /// Downgrading consistency retry policy - retries with lower consistency level if it knows\ @@ -47,10 +47,10 @@ impl Default for DowngradingConsistencyRetrySession { } impl RetrySession for DowngradingConsistencyRetrySession { - fn decide_should_retry(&mut self, query_info: QueryInfo) -> RetryDecision { - let cl = match query_info.consistency { + fn decide_should_retry(&mut self, request_info: RequestInfo) -> RetryDecision { + let cl = match request_info.consistency { Consistency::Serial | Consistency::LocalSerial => { - return match query_info.error { + return match request_info.error { RequestAttemptError::DbError(DbError::Unavailable { .. }, _) => { // JAVA-764: if the requested consistency level is serial, it means that the operation failed at // the paxos phase of a LWT. @@ -85,14 +85,14 @@ impl RetrySession for DowngradingConsistencyRetrySession { decision } - match query_info.error { + match request_info.error { // Basic errors - there are some problems on this node // Retry on a different one if possible RequestAttemptError::BrokenConnectionError(_) | RequestAttemptError::DbError(DbError::Overloaded, _) | RequestAttemptError::DbError(DbError::ServerError, _) | RequestAttemptError::DbError(DbError::TruncateError, _) => { - if query_info.is_idempotent { + if request_info.is_idempotent { RetryDecision::RetryNextNode(None) } else { RetryDecision::DontRetry @@ -139,7 +139,7 @@ impl RetrySession for DowngradingConsistencyRetrySession { }, _, ) => { - if self.was_retry || !query_info.is_idempotent { + if self.was_retry || !request_info.is_idempotent { RetryDecision::DontRetry } else { self.was_retry = true; @@ -159,7 +159,7 @@ impl RetrySession for DowngradingConsistencyRetrySession { } } } - // The node is still bootstrapping it can't execute the query, we should try another one + // The node is still bootstrapping it can't execute the request, we should try another one RequestAttemptError::DbError(DbError::IsBootstrapping, _) => { RetryDecision::RetryNextNode(None) } @@ -197,12 +197,12 @@ mod tests { Consistency::Two, ]; - fn make_query_info_with_cl( + fn make_request_info_with_cl( error: &RequestAttemptError, is_idempotent: bool, cl: Consistency, - ) -> QueryInfo<'_> { - QueryInfo { + ) -> RequestInfo<'_> { + RequestInfo { error, is_idempotent, consistency: cl, @@ -216,13 +216,13 @@ mod tests { ) { let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl(&error, false, cl)), + policy.decide_should_retry(make_request_info_with_cl(&error, false, cl)), RetryDecision::DontRetry ); let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl(&error, true, cl)), + policy.decide_should_retry(make_request_info_with_cl(&error, true, cl)), RetryDecision::DontRetry ); } @@ -304,13 +304,13 @@ mod tests { ) { let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl(&error, false, cl)), + policy.decide_should_retry(make_request_info_with_cl(&error, false, cl)), RetryDecision::DontRetry ); let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl(&error, true, cl)), + policy.decide_should_retry(make_request_info_with_cl(&error, true, cl)), RetryDecision::RetryNextNode(None) ); } @@ -358,13 +358,13 @@ mod tests { for &cl in CONSISTENCY_LEVELS { let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl(&error, false, cl)), + policy.decide_should_retry(make_request_info_with_cl(&error, false, cl)), RetryDecision::RetryNextNode(None) ); let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl(&error, true, cl)), + policy.decide_should_retry(make_request_info_with_cl(&error, true, cl)), RetryDecision::RetryNextNode(None) ); } @@ -388,22 +388,22 @@ mod tests { let mut policy_not_idempotent = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( policy_not_idempotent - .decide_should_retry(make_query_info_with_cl(&error, false, cl)), + .decide_should_retry(make_request_info_with_cl(&error, false, cl)), max_likely_to_work_cl(alive, cl) ); assert_eq!( policy_not_idempotent - .decide_should_retry(make_query_info_with_cl(&error, false, cl)), + .decide_should_retry(make_request_info_with_cl(&error, false, cl)), RetryDecision::DontRetry ); let mut policy_idempotent = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy_idempotent.decide_should_retry(make_query_info_with_cl(&error, true, cl)), + policy_idempotent.decide_should_retry(make_request_info_with_cl(&error, true, cl)), max_likely_to_work_cl(alive, cl) ); assert_eq!( - policy_idempotent.decide_should_retry(make_query_info_with_cl(&error, true, cl)), + policy_idempotent.decide_should_retry(make_request_info_with_cl(&error, true, cl)), RetryDecision::DontRetry ); } @@ -428,7 +428,7 @@ mod tests { // Not idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &enough_responses_no_data, false, cl @@ -436,7 +436,7 @@ mod tests { RetryDecision::RetrySameNode(None) ); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &enough_responses_no_data, false, cl @@ -447,7 +447,7 @@ mod tests { // Idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &enough_responses_no_data, true, cl @@ -455,7 +455,7 @@ mod tests { RetryDecision::RetrySameNode(None) ); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &enough_responses_no_data, true, cl @@ -479,7 +479,7 @@ mod tests { // Not idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &enough_responses_with_data, false, cl @@ -490,7 +490,7 @@ mod tests { // Idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &enough_responses_with_data, true, cl @@ -516,7 +516,7 @@ mod tests { // Not idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( ¬_enough_responses_with_data, false, cl @@ -525,7 +525,7 @@ mod tests { ); if let RetryDecision::RetrySameNode(new_cl) = expected_decision { assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( ¬_enough_responses_with_data, false, new_cl.unwrap_or(cl) @@ -537,7 +537,7 @@ mod tests { // Idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( ¬_enough_responses_with_data, true, cl @@ -546,7 +546,7 @@ mod tests { ); if let RetryDecision::RetrySameNode(new_cl) = expected_decision { assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( ¬_enough_responses_with_data, true, new_cl.unwrap_or(cl) @@ -557,7 +557,7 @@ mod tests { } } - // WriteTimeout will retry once when the query is idempotent and write_type == BatchLog + // WriteTimeout will retry once when the request is idempotent and write_type == BatchLog #[test] fn downgrading_consistency_write_timeout() { setup_tracing(); @@ -577,7 +577,7 @@ mod tests { // Not idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_batchlog, false, cl @@ -588,7 +588,7 @@ mod tests { // Idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_batchlog, true, cl @@ -596,7 +596,7 @@ mod tests { RetryDecision::RetrySameNode(None) ); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_batchlog, true, cl @@ -620,7 +620,7 @@ mod tests { // Not idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_unlogged_batch, false, cl @@ -631,7 +631,7 @@ mod tests { // Idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_unlogged_batch, true, cl @@ -639,7 +639,7 @@ mod tests { max_likely_to_work_cl(received, cl) ); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_unlogged_batch, true, cl @@ -663,7 +663,7 @@ mod tests { // Not idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_other, false, cl @@ -674,7 +674,7 @@ mod tests { // Idempotent let mut policy = DowngradingConsistencyRetryPolicy::new().new_session(); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_other, true, cl @@ -682,7 +682,7 @@ mod tests { RetryDecision::IgnoreWriteError ); assert_eq!( - policy.decide_should_retry(make_query_info_with_cl( + policy.decide_should_retry(make_request_info_with_cl( &write_type_other, true, cl diff --git a/scylla/src/policies/retry/fallthrough.rs b/scylla/src/policies/retry/fallthrough.rs index 48a866e5f..6a9600026 100644 --- a/scylla/src/policies/retry/fallthrough.rs +++ b/scylla/src/policies/retry/fallthrough.rs @@ -1,4 +1,4 @@ -use super::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}; +use super::{RequestInfo, RetryDecision, RetryPolicy, RetrySession}; /// Forwards all errors directly to the user, never retries #[derive(Debug)] @@ -24,7 +24,7 @@ impl RetryPolicy for FallthroughRetryPolicy { } impl RetrySession for FallthroughRetrySession { - fn decide_should_retry(&mut self, _query_info: QueryInfo) -> RetryDecision { + fn decide_should_retry(&mut self, _query_info: RequestInfo) -> RetryDecision { RetryDecision::DontRetry } diff --git a/scylla/src/policies/retry/mod.rs b/scylla/src/policies/retry/mod.rs index f065e6a88..9076673e3 100644 --- a/scylla/src/policies/retry/mod.rs +++ b/scylla/src/policies/retry/mod.rs @@ -8,4 +8,4 @@ pub use downgrading_consistency::{ DowngradingConsistencyRetryPolicy, DowngradingConsistencyRetrySession, }; pub use fallthrough::{FallthroughRetryPolicy, FallthroughRetrySession}; -pub use retry_policy::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}; +pub use retry_policy::{RequestInfo, RetryDecision, RetryPolicy, RetrySession}; diff --git a/scylla/src/policies/retry/retry_policy.rs b/scylla/src/policies/retry/retry_policy.rs index 2b48a608d..7507db378 100644 --- a/scylla/src/policies/retry/retry_policy.rs +++ b/scylla/src/policies/retry/retry_policy.rs @@ -1,19 +1,19 @@ -//! Query retries configurations\ -//! To decide when to retry a query the `Session` can use any object which implements +//! Request retries configurations\ +//! To decide when to retry a request the `Session` can use any object which implements //! the `RetryPolicy` trait use crate::errors::RequestAttemptError; use crate::frame::types::Consistency; -/// Information about a failed query -pub struct QueryInfo<'a> { - /// The error with which the query failed +/// Information about a failed request +pub struct RequestInfo<'a> { + /// The error with which the request failed pub error: &'a RequestAttemptError, - /// A query is idempotent if it can be applied multiple times without changing the result of the initial application\ + /// A request is idempotent if it can be applied multiple times without changing the result of the initial application\ /// If set to `true` we can be sure that it is idempotent\ /// If set to `false` it is unknown whether it is idempotent pub is_idempotent: bool, - /// Consistency with which the query failed + /// Consistency with which the request failed pub consistency: Consistency, } @@ -25,18 +25,18 @@ pub enum RetryDecision { IgnoreWriteError, } -/// Specifies a policy used to decide when to retry a query +/// Specifies a policy used to decide when to retry a request pub trait RetryPolicy: std::fmt::Debug + Send + Sync { - /// Called for each new query, starts a session of deciding about retries + /// Called for each new request, starts a session of deciding about retries fn new_session(&self) -> Box; } -/// Used throughout a single query to decide when to retry it -/// After this query is finished it is destroyed or reset +/// Used throughout a single request to decide when to retry it +/// After this request is finished it is destroyed or reset pub trait RetrySession: Send + Sync { - /// Called after the query failed - decide what to do next - fn decide_should_retry(&mut self, query_info: QueryInfo) -> RetryDecision; + /// Called after the request failed - decide what to do next + fn decide_should_retry(&mut self, request_info: RequestInfo) -> RetryDecision; - /// Reset before using for a new query + /// Reset before using for a new request fn reset(&mut self); } diff --git a/scylla/tests/integration/execution_profiles.rs b/scylla/tests/integration/execution_profiles.rs index 5c19496a3..8c732472b 100644 --- a/scylla/tests/integration/execution_profiles.rs +++ b/scylla/tests/integration/execution_profiles.rs @@ -97,9 +97,9 @@ impl RetryPolicy for BoundToPredefinedNodePolicy { impl RetrySession for BoundToPredefinedNodePolicy { fn decide_should_retry( &mut self, - query_info: scylla::policies::retry::QueryInfo, + request_info: scylla::policies::retry::RequestInfo, ) -> scylla::policies::retry::RetryDecision { - self.report_consistency(query_info.consistency); + self.report_consistency(request_info.consistency); scylla::policies::retry::RetryDecision::DontRetry }